@syncfusion/ej2-querybuilder 25.1.42 → 25.2.3

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.
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * filename: ej2-querybuilder.min.js
3
- * version : 25.1.42
3
+ * version : 25.2.3
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,o,i,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 o(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(o.prototype=l.prototype,new o)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,o=arguments.length;l<o;l++){t=arguments[l];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)},p=function(e,t,l,o){var i,n=arguments.length,r=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,l):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,l,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(r=(n<3?i(r):n>3?i(t,l,r):i(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(!1)],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 i=e.call(this,t,l)||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,o.MultiSelect.Inject(o.CheckBoxSelection),i}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"),o=0,i=l.length;o<i;o++)l[o].className.indexOf("e-tooltip")>-1?t.getComponent(l[o],"tooltip").destroy():l[o].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[o].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=[],o=void 0,i=!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"===(o=typeof(r=this.dataColl[0][d[a].field]))?n=!isNaN(Date.parse(r)):"object"===o&&(n=r instanceof Date&&!isNaN(r.getTime()),o="string"),d[a].type=o,n=!1),o="string"),d[a].validation||(d[a].validation=s),d[a].category?i=!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"]);i&&(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"===(o=typeof(r=this.dataColl[0][e[a]]))?n=!isNaN(Date.parse(r)):"object"!==o||Object.keys(r).length||(n=r instanceof Date&&!isNaN(r.getTime()),o="string"),t[a]={field:e[a],label:e[a],type:n?"date":o,validation:s},n=!1,t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===o&&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 o;t.columns=[];var i,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]];i=typeof n,o={field:t.field+this.separator+r[s],label:r[s],type:i="object"!==i||isNaN(Date.parse(n))?i:"date"},"object"!==i&&(o.operators=this.customOperators[i+"Operator"]),t.columns.push(o),"object"===i&&this.updateSubFields(n,o,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 o=this,i=0;i<e.operators.length;i++)!function(t){var l=Object.keys(e.operators[t]).indexOf("sqlOperator");if(l>-1){var i=e.operators[t],n=Object.keys(i),r=n.map(function(e){return i[""+e]}).join(",").split(","),s=n.indexOf("value");o.operators[r[s]]=r[l]}}(i)}},c.prototype.focusEventHandler=function(e){this.target=e.target},c.prototype.clickEventHandler=function(e){var l,o=this,i=e.target;this.isImportRules=!1;var n;if("SPAN"===i.tagName&&(i=i.parentElement),i.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"===i.tagName&&i.className.indexOf("e-qb-toggle")<0)switch(!0){case i.className.indexOf("e-removerule")>-1:this.actionButton=i,this.deleteRule(i);break;case i.className.indexOf("e-clone-rule-btn")>-1:this.actionButton=i,this.cloneRuleBtnClick=!0,this.ruleClone(i);break;case i.className.indexOf("e-lock-rule-btn")>-1:this.actionButton=i,this.ruleLock(i);break;case i.className.indexOf("e-lock-grp-btn")>-1:this.actionButton=i,this.groupLock(i);break;case i.className.indexOf("e-clone-grp-btn")>-1:this.actionButton=i,this.cloneGrpBtnClick=!0,this.groupClone(t.closest(i,".e-group-container"));break;case i.className.indexOf("e-deletegroup")>-1:this.actionButton=i,this.deleteGroup(t.closest(i,".e-group-container"));break;case i.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"===i.tagName&&i.parentElement.className.indexOf("e-btn-group")>-1||i.className.indexOf("e-qb-toggle")>-1){var p=t.closest(i,".e-group-container");if(!this.headerTemplate){var c=i.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(i.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,i):this.trigger("beforeChange",l,function(e){o.beforeSuccessCallBack(e,i)}),this.target=i}},c.prototype.beforeSuccessCallBack=function(e,l){if(!e.cancel){var o=t.closest(l,".e-group-container"),i=o.id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),r=this.getParentGroup(o);r.condition=e.value,this.enableNotCondition&&(r.not=e.not),this.isImportRules||this.trigger("change",{groupID:i,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,o,i,n,r){var s,a,u,d=e.querySelector(".e-rule-list");if("change"===o?s=t.select("#"+i,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,o,i,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,o,i,n)):this.trigger("beforeChange",s,function(s){r.addRuleSuccessCallBack(s,e,t,l,o,i,n)})}},c.prototype.addRuleSuccessCallBack=function(e,l,i,n,r,s,a){var u,p,c,h,m=this.element.className.indexOf("e-device")>-1?"250px":"200px",g=i&&i.field?this.getColumn(i.field):n||this.columns[0],f={label:"",field:"",type:"",operator:""};if(!e.cancel){if(g&&g.ruleTemplate&&i.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(i).length?i: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,i,f,a,s),!g||g&&!g.ruleTemplate||!i.field)if("Default"===this.fieldMode){var S=void 0,x=void 0;x=this.separator&&i.field?this.GetRootColumnName(i.field):this.autoSelectField?this.GetRootColumnName(i.field):this.isImportRules?this.GetRootColumnName(i.field):i.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:i?x:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(S=d({},S,this.fieldModel)),(c=new o.DropDownList(S)).appendTo("#"+h.id+"_filterkey");w=void 0;w=this.separator&&i.field?this.GetRootColumnName(i.field):this.isImportRules?this.GetRootColumnName(i.field):c.value,this.selectedColumn=c.getDataByValue(w),Object.keys(i).length&&this.changeRule(i,{element:c.element,itemData:this.selectedColumn})}else{var S=void 0,x=(this.isImportRules,i.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 o.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(i.field)?O.value:this.GetRootColumnName(i.field);this.selectedColumn=this.getColumn(w),Object.keys(i).length&&this.changeRule(i,{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,o,i,n){var r,s,a,u=0;if(i){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&&(o.custom=d),this.autoSelectField&&(l.field=o.field=this.rule.rules[0].field),a.rules.push(o))}this.disableRuleCondition(e,a)},c.prototype.changeRuleTemplate=function(e,l){var o=this.selectedColumn.operators;if(!e.ruleTemplate){var i=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:o[0].value,value:""};this.addRuleElement(i,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 o=["isnull","isnotnull","isempty","isnotempty"],i=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(i=0,n=m.length;i<n;i++){var g=void 0;if(u=t.closest(m[i],".e-group-container"),h=this.getParentGroup(u),d=0,s=c=m[i],"DropdownTree"===this.fieldMode?(e=t.getComponent(m[i].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[i].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),o.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,o,i=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,r=i.length,s=0;for(o=0;o<r;o++)(l=i[o]).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,o,i,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),o=this.createElement("div",{attrs:{class:"e-group-action"}}),i=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),o.appendChild(i),r.appendChild(o)),n},c.prototype.ruleTemplate=function(){var e,l,o,i,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"}}),o=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",i=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:o}}),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:i}});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,o,i,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,o,i,n,r)):this.trigger("beforeChange",a,function(a){s.addGroupSuccess(a,e,t,l,o,i,n,r)})},c.prototype.addGroupSuccess=function(e,o,i,n,r,a,u,d){if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var p=i,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?(o=!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(o){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 D={requestType:"header-template-create",ruleID:m.id,condition:n,notCondition:this.enableNotCondition?a:void 0};this.trigger("actionBegin",D)}else{var T=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,T),select:this.selectBtn.bind(this,T)}).appendTo(T),T.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,o,i,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:o,rule:this.getRuleCollection(i,!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,o){var i=t.closest(l,".e-group-container"),n=this.getParentGroup(i),r=t.closest(l,".e-rule-container"),s=0;if("not"===o)return void(n.not=e);if("condition"===o)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,o):(this.isNotified=!0,this.updateRules(l,e),this.isNotified=!1)},c.prototype.templateChange=function(e,l,o){var i,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"===o?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(o){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),o),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===o||"operator"===o)){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,o,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:o,ruleID:m.id,fields:this.fields,rule:u};i={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",i)}},c.prototype.changeValue=function(e,l){var o,i=this;((o=l.element&&l.element.classList.contains("e-multiselect")?l.element:l.event?l.event.target:l.element).className.indexOf("e-day")>-1||o.className.indexOf("e-today")>-1||o.className.indexOf("e-cell")>-1)&&(o=l.element);var n,r=t.closest(o,".e-group-container"),s=t.closest(o,".e-rule-container"),a=r&&r.id.replace(this.element.id+"_",""),u=s.id.replace(this.element.id+"_",""),d=l;d.element&&d.element.className.indexOf("e-datepicker")>-1&&(o=d.element,(n=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"))&&(this.selectedColumn=n.getDataByValue(n.value)),(n=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"))&&(this.selectedColumn=this.getColumn(n.value[0])));var p,c;o.className.indexOf("e-radio")>-1?(c=parseInt(o.id.split("valuekey")[1],0),"Default"===this.fieldMode?(n=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=n.getDataByValue(n.value),this.selectedColumn.columns&&(n=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-rule-sub-filter .e-dropdownlist"),"dropdownlist"),this.selectedColumn=this.getColumn(n.value))):(n=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"),this.selectedColumn=this.getColumn(n.value[0])),p=this.selectedColumn.values?this.selectedColumn.values[c]:[!0,!1][c]):p=o.className.indexOf("e-multiselect")>-1?t.getComponent(o,"multiselect").value:l.value,"input"===l.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){i.filterValue(a,u,p,e,o)},this.immediateModeDelay)):this.filterValue(a,u,p,e,o)},c.prototype.filterValue=function(e,t,l,o,i){var n=this,r={groupID:e,ruleID:t,value:l,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(r,i,o,e,t):this.trigger("beforeChange",r,function(l){n.changeValueSuccessCallBack(l,i,o,e,t)})},c.prototype.changeValueSuccessCallBack=function(e,t,l,o,i){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules||this.trigger("change",{groupID:o,ruleID:i,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"),o=l.popupObj.element.querySelector(".e-active"),i=l.getItemData();l.value=i.value;var n={element:l.element,value:i.value,isInteracted:!0,previousItemData:this.prevItemData,previousItem:null,item:o,itemData:i,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"),o="DropdownTree"===this.fieldMode?this.getColumn(e.value[0]):this.getColumn(e.value);if("DropdownTree"===this.fieldMode&&null!==l){var i=l.querySelector(".e-dropdowntree.e-control"),n=t.getComponent(i,"dropdowntree");if(!o)return;if("object"===o.type){if(n.value=e.oldValue,n.dataBind(),t.isNullOrUndefined(e.oldValue))i.value="";else{r=this.getLabelFromColumn(e.oldValue[0]);i.value=r}return}if(!t.isNullOrUndefined(e.value[0])){n.value=e.value[0],n.dataBind();var r=this.getLabelFromColumn(e.value[0]);i.value=r}}if(this.destroySubFields(l),this.subFieldElem=null,this.isNotValueChange=!0,o&&o.ruleTemplate)this.templateChange(e.element,o.field,"field");else if(o&&o.columns&&o.columns[0].ruleTemplate)this.templateChange(e.element,o.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 o={},i=t.closest(l.element,".e-rule-filter");i=i||t.closest(l.element,".e-rule-sub-filter");var n=t.getComponent(l.element,"dropdownlist");"DropdownTree"===this.fieldMode&&null!==i&&(n=t.getComponent(l.element,"dropdowntree"));var r=t.closest(l.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(i,n,r,e,o,l)},c.prototype.changeFilter=function(e,l,o,i,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:o,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,i,r):this.trigger("beforeChange",u,function(t){s.fieldChangeSuccess(t,n,e,i,r)})}else{var d=t.closest(r.element,".e-rule-operator");this.changeOperator(e,d,l,o,i,n,r)}},c.prototype.changeOperator=function(e,l,o,i,n,r,s){var a,u=this;l?(a={groupID:i,ruleID:t.closest(l,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:o.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,o,i,n){for(var r=t.closest(o,".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(o,s,u,a,i,l,n);else{if(t.isNullOrUndefined(this.selectedColumn))return;if(l.type=this.selectedColumn.type,r.querySelector(".e-template")&&(i.value=""),"object"===this.selectedColumn.type&&"Default"===this.fieldMode)for(l.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(o,i,l,n);else this.destroySubFields(o),this.changeOperator(o,s,u,a,i,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,i,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 o.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,i,n)},c.prototype.operatorChangeSuccess=function(e,l,o,i,n){if(!e.cancel){var r=t.closest(n.element,".e-rule-operator"),s=r.nextElementSibling,a=t.getComponent(n.element,"dropdownlist"),u=i.operator?i.operator.toString().toLowerCase():"";o.operator=a.value.toString();var d=o.operator.toLowerCase();if(o.operator.toLowerCase().indexOf("between")>-1||o.operator.toLowerCase().indexOf("in")>-1&&o.operator.toLowerCase().indexOf("contains")<0?(l=r.previousElementSibling,o.type=i.type,(o.operator.toLowerCase().indexOf("in")<0||u.indexOf("in")<0)&&(i.value=[])):"object"==typeof i.value&&null!==i.value&&(i.value=i.value.length>0?i.value[0]:"number"===i.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,o.type=i.type)}if(u.indexOf("in")>-1&&u.indexOf("in")<5&&d.indexOf("in")>-1&&d.indexOf("in")<5&&(l=null),o.operator.indexOf("null")>-1||o.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(i.field).template&&(l=r.previousElementSibling),0==s.children.length&&(l=r.previousElementSibling),this.changeRuleValues(l,i,o,n)}},c.prototype.changeRuleValues=function(e,l,i,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")&&(i.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"),i.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"),i.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,i,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 o.DropDownList(v).appendTo("#"+h+"_operatorkey"),i.operator=l&&""!==l.operator&&!t.isNullOrUndefined(l.operator)?l.operator:s[0].value,this.isImportRules&&(i.type=this.selectedColumn.type,i.operator=l.operator),t.isNullOrUndefined(g)||""===g?this.autoSelectField&&this.autoSelectOperator&&this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,i,n.element):this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,i,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 o=l?e:e.nextElementSibling,i=o.querySelectorAll("input.e-control"),n=o.querySelectorAll("div.e-control:not(.e-handle)"),r=this.columns,s=0,a=i.length;s<a;s++){if(i[s].classList.contains("e-textbox"))t.getComponent(i[s],"textbox").destroy(),t.detach(t.select("input#"+i[s].id,o));else if(i[s].classList.contains("e-dropdownlist"))this.allowValidation&&i[s].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(i[s].parentElement,"tooltip").destroy(),t.getComponent(i[s],"dropdownlist").destroy();else if(i[s].classList.contains("e-radio"))t.getComponent(i[s],"radio").destroy();else if(i[s].classList.contains("e-numerictextbox"))t.getComponent(i[s],"numerictextbox").destroy(),t.detach(t.select("input#"+i[s].id,o));else if(i[s].classList.contains("e-datepicker"))t.getComponent(i[s],"datepicker").destroy();else if(i[s].classList.contains("e-multiselect"))t.getComponent(i[s],"multiselect").destroy();else if(i[s].className.indexOf("e-template")>-1)for(var u=i[s].className,d=0,p=r.length;d<p;d++)if(r[d].template&&u.indexOf(r[d].field)>-1){this.templateDestroy(r[d],i[s].id);break}document.getElementById(i[s].id)&&t.detach(i[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=o.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 o;if("string"!=typeof e.template||void 0===e.template.destroy){var i=(o=e.template).destroy;if(o.destroy){var n=void 0;document.getElementById(l)&&(n=t.closest(document.getElementById(l),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof i?(i=t.getValue(i,window))({field:e.field,elementId:l,elements:n}):o.destroy({field:e.field,elementId:l,elements:n})}}},c.prototype.getValues=function(e){var t,l={},o=[],i=[];this.separator.length>0&&(i=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(i.length>1)for(var u=n[r],d=void 0,p=0,c=i.length;p<c;p++)d=i[p],i.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,i.length>1?this.createNestedObject(a,i,t):a[""+e]=t,o.push(a))}return o},c.prototype.createNestedObject=function(e,t,l){for(var o,i=t.length-1,n=0;n<i;++n)(o=t[n])in e||(e[""+o]={}),e=e[""+o];e[t[i]]=l},c.prototype.getDistinctValues=function(e,t){for(var l={},o=[],i=[],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]:(i=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[i[i.length-1]]=n,o.push(d))}(a);return o},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 i.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 o.MultiSelect(p);c.appendTo("#"+t+"_valuekey"+l),this.updateRules(c.element,n,0)},c.prototype.multiSelectOpen=function(e,l){if(this.dataSource instanceof i.DataManager){var o=document.getElementById(e),n=t.getComponent(t.closest(o,".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(o,r))}},c.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},c.prototype.getMultiSelectData=function(e,l){var o,n=this,r=new i.Deferred,s=this.dataManager.executeQuery((new i.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(i){o=i.actual&&i.actual.result?i.actual.result:i.result,n.dataColl=t.extend(n.dataColl,o,[],!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 o=document.getElementById(l.popup.element.id.replace("_popup",""));if(o){var i=t.getComponent(o,"multiselect").value;this.updateRules(o,i,e)}},c.prototype.processTemplate=function(e,l,o,i){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:o,ruleID:n.id,operator:i.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:o.value,operator:i.operator,field:u.field,dataSource:u.values}):"function"!=typeof l.template&&l.template.write({elements:r.length>1?r:r[0],values:o.value,operator:i.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,o){var i=this.getItemData(e);if(t.isNullOrUndefined(i.value))return o?l?[0,0]:0:l?[]:"";if(l){if(!(i.value instanceof Array))return[i.value]}else if(i.value instanceof Array)return i.value[0];return i.value},c.prototype.renderStringValue=function(e,t,l,o,i){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,o)},this.valueModel&&this.valueModel.textBoxModel&&(p=d({},p,this.valueModel.textBoxModel));var c=new n.TextBox(p);c.appendTo("#"+e+"_valuekey"+o),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,o,r,a.values),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?i.style.width="100%":(i.style.width=null,i.style.minWidth="200px")},c.prototype.renderNumberValue=function(e,t,l,o,i,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,o)},this.valueModel&&this.valueModel.textBoxModel&&(h=d({},h,this.valueModel.textBoxModel));var m=new n.TextBox(h);m.appendTo("#"+e+"_valuekey"+o),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[o]?t.value[o]:this.setDefaultValue(e,!0,!0));var y=void 0;y={value:p instanceof Array?p[o]:p,format:v,min:g,max:f,width:"100%",step:r.step?r.step:1,change:this.changeValue.bind(this,o)},this.valueModel&&this.valueModel.numericTextBoxModel&&(y=d({},y,this.valueModel.numericTextBoxModel));var b=new n.NumericTextBox(y);b.appendTo("#"+e+"_valuekey"+o),b.element.setAttribute("aria-label",r.label+" Value")}else p=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,o,p,a.values),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null)},c.prototype.processValueString=function(e,t){var l=[],o=e.split(",");if("string"===t)return o;for(var i=0,n=o.length;i<n;i++)l.push(Number(o[i]));return l},c.prototype.parseDate=function(e,l){var o,i;if(l){var n=this.intl.getDateParser({skeleton:"full",type:"dateTime"});o=this.getFormat(l),i=n(e),t.isNullOrUndefined(i)&&(i=this.intl.parseDate(e,o))}else i=new Date(e);return i},c.prototype.renderControls=function(e,l,o,i,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,o,i);else{var s;s="boolean"===i.type?this.selectedColumn.values?this.selectedColumn.values.length:2:i.operator&&i.operator.toString().toLowerCase().indexOf("between")>-1?2:1;var a=t.closest(e,".e-rule-container").id,u=void 0,p=i.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(i.type){case"string":this.renderStringValue(a,o,p,c,u);break;case"number":this.renderNumberValue(a,o,p,c,u,l,s);break;case"boolean":this.processBoolValues(l,o,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(o.value&&!t.isNullOrUndefined(f)&&(m=s>1?o.value[c]:o.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&&o&&""!==o.field&&(f=(g=this.getColumn(o.field)).format),(this.isImportRules||this.isPublic||C)&&o&&(f=(g=this.getColumn(o.field)).format,o.value?(m=s>1?o.value[c]:o.value,h=this.parseDate(m,g.format)):h=o.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),!o.value){var x=document.getElementById(a+"_valuekey"+c);this.updateRules(x,h,null,this.isNotValueChange),this.isNotValueChange=!1}}}}},c.prototype.processBoolValues=function(e,o,i,n){var r,s,a=!1;t.isNullOrUndefined(o.type)&&e&&(o.type=e.type);var u;if(e.values){p=e.values;"boolean"!==o.type||t.isNullOrUndefined(o.value)?e.value?a=p[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toLowerCase()===o.value.toString().toLowerCase(),s=r=u=p[n]}else{var p=[!0,!1];"boolean"!==o.type||t.isNullOrUndefined(o.value)?e.value?a=p[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a="boolean"!=typeof o.value||!!o.value):a=p[n].toString().toLowerCase()===o.value.toString().toLowerCase(),"boolean"==typeof o.value&&1===n&&(a=!o.value),r=p[n].toString(),s=p[n],u=this.l10n.getConstant(["True","False"][n])}var c;c={label:u,name:i+"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("#"+i+"_valuekey"+n),a&&this.updateRules(h.element,s,0,!0)},c.prototype.getOperatorIndex=function(e,t){var l,o=e.dataSource.length;for(l=0;l<o;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,o,i,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");i&&(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(o=this.getPreviousItemData(o,d),o&&void 0===o.template?o.columns&&(o=this.getColumn(n.field)):"DropdownTree"===this.fieldMode&&void 0===o&&(o=this.getColumn(n.field)),o&&o.template){this.templateDestroy(o,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 o.template&&void 0!==o.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([m]),e.nextElementSibling.innerHTML="")}if(i&&(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,o,i,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:o,operator:i,rule:r,renderTemplate:!0},this.trigger("actionBegin",s,function(t){u=a.actionBeginSuccessCallBack(t,e,l,o,n)}),u;var d=void 0,p=e.template;if((d="string"==typeof p.create?t.getValue(p.create,window)({field:o,operator:i}):p.create({field:o,operator:i}))instanceof Element)d.id=l+"_valuekey0",t.addClass([d],"e-template"),n.nextElementSibling.appendChild(d),o.indexOf(" ")<0&&t.addClass([d],"e-"+o);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,o,i,n){if(e.renderTemplate){var r=void 0;this.columnTemplateFn=this.templateParser((l.template,l.template));var s=this.element.id+i;if(this.isReact)r=this.columnTemplateFn(e,this,o,s)[0],n.nextElementSibling.appendChild(r);else if(this.isAngular){var a=this.columnTemplateFn(e,this,o,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 o=1;e.className.indexOf("e-template")>-1&&(o=3);var i=e.className.split(" e-")[o],n=parseInt(e.id.slice(-1),2);switch(i){case"checkbox":var r=t.getComponent(e,i).value;l.value=""!==r?r:void 0;break;case"textbox":case"dropdownlist":l.value=t.getComponent(e,i).value;break;case"radio":var s=t.getComponent(e,i);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,i).value):l.value=t.getComponent(e,i).value;break;case"datepicker":var a=this.getColumn(l.field),u=this.getFormat(a.format),d=t.getComponent(e,i).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,i).value}},c.prototype.updateRules=function(e,l,o,i){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,o),i||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,o,i,n,r){var s,a,u=["in","between","notin","notbetween"];if(l.rules[o].operator&&(a=l.rules[o].operator.toString().toLowerCase()),null!==t){if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[o].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[o].value=t,s={groupID:i.id,ruleID:n.id,value:l.rules[o].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[o].value[r]=t:l.rules[o].value=t;else if(e.className.indexOf("e-radio")>-1)l.rules[o].value=t;else if(e.className.indexOf("e-multiselect")>-1)l.rules[o].value=t;else if(e.className.indexOf("e-textbox")>-1)"in"===a||"notin"===a?(l.rules[o].type,l.rules[o].value=this.processValueString(t,l.rules[o].type)):l.rules[o].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[o].value&&(l.rules[o].value=[]),l.rules[o].value[r]=this.intl.formatDate(t,m)):l.rules[o].value=this.intl.formatDate(t,m))}this.validateValue(l,n,o)}else e.className.indexOf("e-datepicker")>-1&&u.indexOf(a)>-1?("string"==typeof l.rules[o].value&&(l.rules[o].value=[]),l.rules[o].value[r]=t):l.rules[o].value=t},c.prototype.validateValue=function(e,l,o){t.isNullOrUndefined(o)||(e=e.rules[o]);var i="object"==typeof e.value;if(this.allowValidation&&(t.isNullOrUndefined(o)||(i?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 o=t.rules,i=[];if(!l){for(var n=0,r=o.length;n<r;n++)(t=o[n]).rules&&i.push(t);return i[e]}return t},c.prototype.destroy=function(){if(this.isDestroy=!0,this.element){var l,o,i,n;e.prototype.destroy.call(this);var r;for(i=(l=this.element.querySelectorAll(".e-addrulegroup")).length,o=0;o<i;o++)t.getComponent(l[o],"dropdown-btn").destroy(),t.detach(l[o]);for(n=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),o=0;o<n.length;o++)t.getComponent(n[o],"tooltip").destroy();for(i=(l=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,o=0;o<i;o++)t.getComponent(l[o],"dropdownlist")?t.getComponent(l[o],"dropdownlist").destroy():t.getComponent(l[o],"dropdowntree").destroy(),t.detach(l[o]);for(n=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),o=0;o<n.length;o++)t.getComponent(n[o],"tooltip").destroy();for(i=(l=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,o=0;o<i;o++)t.getComponent(l[o],"dropdownlist")&&(t.getComponent(l[o],"dropdownlist").destroy(),t.detach(l[o]));for(n=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),o=0;o<n.length;o++)t.getComponent(n[o],"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"))for(o=0;o<r.length;o++)r[o].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,o=e.length;l<o;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),o=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var i=0,n=e.length;i<n;i++)this.updatedRule={isLocked:e[i].isLocked,condition:e[i].condition,not:e[i].not},this.importRules(e[i],l,!1,e[i].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?o.rules.push({condition:r,not:s,rules:[]}):o.rules.push({condition:r,rules:[]}):this.enableNotCondition?o.rules.splice(this.groupIndex+1,0,{condition:r,not:s,rules:[],isLocked:a}):o.rules.splice(this.groupIndex+1,0,{condition:r,rules:[],isLocked:a})}this.headerTemplate||this.disableRuleCondition(l,o)}},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"),o=void 0,i=0;i<l.length;i++)o=l.item(i),t.rippleEffect(o,{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"}}),o=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),o.appendChild(l),e.appendChild(o),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 i.DataManager(this.columns).executeLocal((new i.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new i.DataManager(this.columns).executeLocal((new i.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 o=0;o<e.rules.length;o++)l=e.rules[o],l=this.checkNotGroup(l),e.rules[o]=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 o=0,i=Object.keys(e);o<i.length;o++)switch(i[o]){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 i.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new i.Query).take(1))):(this.dataManager=new i.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new i.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),o=new i.Deferred;l.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){o.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],o=t?l.length-1:l.length,i=this.rule,n=0;n<o;n++)i=this.findGroupByIdx(l[n],i,0===n);return i},c.prototype.deleteGroup=function(e){var t,l=this,o=e;"string"==typeof e?(t=this.element.id+"_"+e,e=document.getElementById(t)):t=o.id.replace(this.element.id+"_","");var i={groupID:t,cancel:!1,type:"deleteGroup"};this.isImportRules?this.deleteGroupSuccessCallBack(i,e):this.trigger("beforeChange",i,function(t){l.deleteGroupSuccessCallBack(t,e)})},c.prototype.deleteGroupSuccessCallBack=function(e,l){if(!e.cancel){var o=l,i=this.getParentGroup(o,!0),n=0,r=void 0,s=void 0,a=this.getValidRules(this.rule),u=o.nextElementSibling,d=o.previousElementSibling,p=o.querySelectorAll(".e-group-container"),c=o.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!==o.previousElementSibling;)o=o.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=o.parentElement.parentElement.parentElement,m=[];if(this.isReact||this.isAngular){var g=i.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),i.rules.splice(n,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(h,i),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,o={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(o,e):this.trigger("beforeChange",o,function(t){l.deleteRuleSuccessCallBack(t,e)})},c.prototype.deleteRuleSuccessCallBack=function(e,l){if(!e.cancel){var o=t.closest(l,".e-group-container"),i=this.getParentGroup(o),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(i.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]),i.rules.splice(d,1),i.rules[0]&&i.rules[0].rules||this.disableRuleCondition(o,i);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,o=e.querySelector(".e-btngroup-and"),i=e.querySelector(".e-btngroup-or");l>1?(o.disabled=!1,i.disabled=!1,(i.nextElementSibling.classList.contains("e-btn-disable")||o.nextElementSibling.classList.contains("e-btn-disable"))&&(i.nextElementSibling.classList.remove("e-btn-disable"),o.nextElementSibling.classList.remove("e-btn-disable")),t&&"or"===t.condition?i.checked=!0:o.checked=!0):(o.checked=!1,o.disabled=!0,i.checked=!1,i.disabled=!0,t&&(i.nextElementSibling.classList.add("e-btn-disable"),o.nextElementSibling.classList.add("e-btn-disable")))}},c.prototype.getValidRules=function(e){e||(e=this.getRules());var l=e.condition,o=e.not,i=t.extend([],e.rules,[],!0);return this.getRuleCollection({condition:l,rules:i,not:o},!0)},c.prototype.getRuleCollection=function(e,l){if(t.isNullOrUndefined(e))return null;var o;if(e.rules&&e.rules.length&&(Object.keys(e.rules[0]).length>6||l))for(var i=e.rules.length,n=0;n<i;n++)o=e.rules[n],o=this.getRuleCollection(o,l),e.rules[n]=o,Object.keys(o).length<1&&l&&(e.rules.splice(n,1),n--,i--);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;e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value,isLocked:e.isLocked},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)t.isNullOrUndefined(e.condition)&&t.isNullOrUndefined(e.rules)?e={}:(e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not,isLocked:e.isLocked}:{condition:e.condition,rules:e.rules,isLocked:e.isLocked},r&&(e.custom=r),0===e.rules.length&&(e={}));else{var a=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=a)}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},this.rule.custom&&(e.custom=this.rule.custom),e},c.prototype.getRule=function(e){var l,o,i=0;if(e instanceof HTMLElement?l=t.closest(e,".e-rule-container"):(o=this.element.id+"_"+e,l=document.getElementById(o)),t.isNullOrUndefined(l))return null;for(var n=t.closest(l,".e-group-container"),r=this.getParentGroup(n);null!==l.previousElementSibling;)l=l.previousElementSibling,i++;return r.rules[i]},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,o=e.length;for(t=0;t<o;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 i.Query:(new i.Query).where(e);return this.dataManager.executeQuery(l)},c.prototype.deleteRules=function(e){var t,l,o=e.length;for(t=0;t<o;t++)l=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(l))},c.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],o=0,n=Object.keys(this.columns);o<n.length;o++)l.push(this.columns[o].field);return e.rules.length?(new i.Query).select(l).where(t):(new i.Query).select(l)},c.prototype.getPredicate=function(e){var l,o,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)(o=this.getPredicate(s[u]))&&(l=l?"and"===e.condition?l.and(o):l.or(o):o);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 i.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 i.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 i.Predicate(s[u].field,p,n,a))}}}return this.dataSource instanceof i.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,o=this.columns,i=0,n=(o=t||o).length;i<n;i++){if(o[i].field===e){l=o[i];break}if(o[i].columns){if(l=this.getColumn(e,o[i].columns))break}else if(e&&e.indexOf(this.separator)>-1&&""!==this.separator&&o[i].field===e.split(this.separator)[0]){l=o[i];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,o){var n,r=this.setTime(new Date(t.getTime()),!0),s=this.setTime(t);switch(e.operator){case"equal":n=(n=new i.Predicate(e.field,"greaterthanorequal",r)).and(e.field,"lessthanorequal",s);break;case"notequal":n=(n=new i.Predicate(e.field,"lessthan",r)).or(e.field,"greaterthan",s);break;case"greaterthan":n=new i.Predicate(e.field,"greaterthan",s);break;case"greaterthanorequal":n=new i.Predicate(e.field,"greaterthanorequal",r);break;case"lessthan":n=new i.Predicate(e.field,"lessthan",r);break;case"lessthanorequal":n=new i.Predicate(e.field,"lessthanorequal",s)}return n&&(l?"and"===o?l=l.and(n):"or"===o&&(l=l.or(n)):l=n),l},c.prototype.arrayPredicate=function(e,t,l){var o,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":o=new i.Predicate(e.field,"isnull",s);break;case"isnotnull":o=new i.Predicate(e.field,"isnotnull",s);break;case"isempty":o=new i.Predicate(e.field,"equal","");break;case"isnotempty":o=new i.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":o="date"!==a.type?new i.Predicate(e.field,c,n[d]):new i.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":o="date"===a.type?new i.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 i.Predicate(e.field,"lessthan",n[d]);break;case"in":o=new i.Predicate(e.field,"equal",n[d]);break;case"notin":o=new i.Predicate(e.field,"notequal",n[d])}}else{switch(e.operator){case"between":o="date"===a.type?o.and(e.field,"lessthanorequal",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u)):n[d]):o.and(e.field,"lessthanorequal",n[d]);break;case"notbetween":o="date"===a.type?o.or(e.field,"greaterthan",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u)):n[d]):o.or(e.field,"greaterthan",n[d]);break;case"in":o=o.or(e.field,"equal",n[d]);break;case"notin":o=o.and(e.field,"notequal",n[d])}}return o&&(t?"and"===l?t=t.and(o):"or"===l&&(t=t.or(o)):t=o),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,o,i,n){if(o){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,i);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,o,i){this.addGroupElement(!0,l,t,!1,o,i,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"),i=0;i<e.length;i++)e[i].classList.contains("e-dropdownlist")?t.getInstance(e[i],o.DropDownList).readonly=this.isReadonly:e[i].classList.contains("e-dropdowntree")?t.getComponent(e[i],"dropdowntree").readonly=this.isReadonly:e[i].classList.contains("e-numerictextbox")?t.getInstance(e[i],n.NumericTextBox).readonly=this.isReadonly:e[i].classList.contains("e-textbox")?t.getInstance(e[i],n.TextBox).readonly=this.isReadonly:e[i].classList.contains("e-datepicker")?t.getInstance(e[i],r.DatePicker).readonly=this.isReadonly:e[i].classList.contains("e-multiselect")?t.getInstance(e[i],o.MultiSelect).readonly=this.isReadonly:e[i].classList.contains("e-radio")&&(t.getInstance(e[i],l.RadioButton).checked||(this.isReadonly?e[i].parentElement.style.display="none":e[i].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],i=0;i<d.length;i++)d[i].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,o=t.length;l<o;l++)if(e.toLowerCase().indexOf(t[l])>-1)return!0;return!1},c.prototype.getSqlString=function(e,t,l,o){var i=!1;l||""===l?l+="(":(l="",i=!0);var n=e.condition;if(e.not){l+=i?o?this.l10n.getConstant("NOT").toUpperCase()+" (":"NOT (":o?" "+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,o);else{var a=e.rules[r],u="",d=o?this.sqlOperators[a.operator]:this.operators[a.operator];if(a.value instanceof Array)if(a.operator.toString().indexOf("between")>-1){var p=o?" "+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=o?this.l10n.getConstant(n.toUpperCase()).toUpperCase():n.toUpperCase())+" "}}return i||(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 o=this.getRulesFromSql(l);this.setRules({condition:o.condition,not:o.not,rules:o.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 o=this.getRulesFromSql(l);this.setRules({condition:o.condition,not:o.not,rules:o.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 o=this.getRule(e.replace(this.element.id+"_","")),i=this.showButtons.cloneRule;t=t.replace(this.element.id+"_",""),this.ruleIndex=l,this.cloneRuleBtnClick=!0,this.showButtons.cloneRule=!0,this.addRules([{label:o.label,field:o.field,type:o.type,operator:o.operator,value:o.value}],t),this.ruleIndex=-1,this.cloneRuleBtnClick=!1,this.showButtons.cloneRule=i,i=!1},c.prototype.cloneGroup=function(e,t,l){t=t.replace(this.element.id+"_","");var o=this.getGroup(t),i=this.showButtons.cloneGroup;e=e.replace(this.element.id+"_",""),this.groupIndex=l,this.cloneGrpBtnClick=!0,this.showButtons.cloneGroup=!0,this.addGroups([{condition:o.condition,not:o.not,rules:o.rules}],e),this.groupIndex=-1,this.cloneGrpBtnClick=!1,this.showButtons.cloneGroup=i,i=!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,o=0;do{l=e.slice(o),o+=this.parseSqlStrings(l,t)}while(""!==l);return this.parser},c.prototype.parseSqlStrings=function(e,t){var l,o=["=","!=","<=",">=","<",">"];l=t?[this.l10n.getConstant("AND").toUpperCase(),this.l10n.getConstant("OR").toUpperCase(),this.l10n.getConstant("NOT").toUpperCase()]:["AND","OR","NOT"];var i;i=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=o.length;s<a;s++)if(n=/^\w+$/.test(o[s])?"\\b":"",new RegExp("^("+o[s]+")"+n,"ig").exec(e))return this.parser.push(["Operators",o[s].toLowerCase()]),o[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=i.length;s<a;s++)if(n=/^\w+$/.test(i[s])?"\\b":"",new RegExp("^("+i[s]+")"+n,"ig").exec(e))return this.parser.push(["SubOperators",i[s].toLowerCase()]),i[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++);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.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 o=this.parser[this.parser.length-2],i=this.parser[this.parser.length-3];if("Left"===l[0]&&o&&"Conditions"===o[0])return!0;var n=t?this.l10n.getConstant("Between").toLowerCase():"between";if("Conditions"===l[0]&&i&&i[1].indexOf(n)<0)return!0}return!1},c.prototype.getOperator=function(e,t,l){var o={"=":"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 i=Object.keys(this.sqlOperators),n=0;n<i.length;n++)if(this.sqlOperators[i[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":i[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 o[""+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 o=e.split(this.separator),i=0;i<o.length;i++)t+=this.getLabelFromField(o,i+1),++l<o.length&&(t+=this.separator);return t}return this.getColumn(e).label},c.prototype.getLabelFromField=function(e,t){for(var l="",o=0,i=0;i<t;i++)l+=e[i],++o<t&&(l+=this.separator);return this.getColumn(l).label},c.prototype.processParser=function(e,t,l,o){for(var i,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],o),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],o)}for(h=e[v+1][1],i=++v+1,n=y,o&&"contains"===r.operator||"startswith"===r.operator||"endswith"===r.operator?h="like":o&&"notcontains"===r.operator||"notstartswith"===r.operator||"notendswith"===r.operator?h="not like":o&&(h=r.operator),i=v+1;i<n;i++)if(h.indexOf("between")<0&&"Left"===e[i][0])f=!0;else{if("Right"===e[i][0]&&f){v=i,f=!1;break}if(h.indexOf("null")>-1||h.indexOf("empty")>-1)break;if(h.indexOf("like")>-1&&"String"===e[i][0]){S=e[i][1];e[i][1]&&"'"===e[i][1][0]&&(S=e[i][1].substring(1,e[i][1].length-1)),S=S?S.replace(/%/g,""):e[i][1],r.value=S,r.type="string"}else if(h.indexOf("between")>-1){if("Literal"===e[i][0]||"Left"===e[i][0])break;if("Number"===e[i][0])m.push(Number(e[i][1]));else if("String"===e[i][0]){S=e[i][1];e[i][1]&&"'"===e[i][1][0]&&(S=e[i][1].substring(1,e[i][1].length-1)),g.push(S)}}else if("Number"===e[i][0])m.push(Number(e[i][1]));else if("String"===e[i][0]){var S=e[i][1];e[i][1]&&"'"===e[i][1][0]&&(S=e[i][1].substring(1,e[i][1].length-1)),g.push(S)}r.type=this.getTypeFromColumn(r)}h.indexOf("like")<0&&("Number"===e[i-1][0]?(r.value=m,r.type="number"):"String"===e[i-1][0]?(r.value=g,r.type="string"):h.indexOf("between")>-1&&"Conditions"===e[i-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],o),"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",r.value=e[v+2][1]?e[v+2][1].replace(/'/g,""):e[v+2][1]),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]||o&&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,o),t}if("Conditions"===e[v][0])"not"===e[v][1]||o&&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,o)}}return t},c.prototype.groupClone=function(e){var t,l,o=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=o.id.replace(this.element.id+"_",""));var i=this.getGroup(t);this.groupIndex=Array.prototype.indexOf.call(e.closest(".e-rule-list").children,e.closest(".e-group-container")),this.addGroups([{condition:i.condition,not:i.not,rules:i.rules}],l),this.groupIndex=-1},c.prototype.ruleClone=function(e){for(var l=t.closest(e,".e-rule-container"),o=e.closest(".e-rule-list").closest(".e-group-container"),i=this.getRule(e),n=o.id.replace(this.element.id+"_",""),r=o.querySelectorAll(".e-rule-container"),s=0,a=r.length;s<a;s++)l.id===r[s].id&&(this.ruleIndex=s);this.addRules([{label:i.label,field:i.field,type:i.type,operator:i.operator,value:i.value}],n),this.ruleIndex=-1},c.prototype.ruleLock=function(e){var l=t.closest(e,".e-rule-container"),o=this.getRule(l.id.replace(this.element.id+"_",""));l.classList.contains("e-disable")?(o.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"))):(o.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"),o=this.getGroup(l.id.replace(this.element.id+"_","")),i=l.id.indexOf("group0")>-1;if(l.classList.contains("e-disable"))i?((n={}).condition=o.condition,n.not=o.not,n.isLocked=!1,this.setProperties({rule:n},!0)):o.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(i){var n={};n.condition=o.condition,n.not=o.not,n.isLocked=!0,this.setProperties({rule:n},!0)}else o.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]),o=l.querySelector(".e-lock-rule-btn");(l=t.closest(o,".e-rule-container")).classList.contains("e-disable")||this.ruleLock(o)}else{var i=this.element.querySelector("#"+this.lockItems[e]),o=i.querySelector(".e-lock-grp-btn");(i=t.closest(o,".e-group-container")).classList.contains("e-disable")||this.groupLock(o)}},c.prototype.disableHeaderControls=function(e,t,l){for(var o=t.querySelectorAll(".e-btngroup-and"),i=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<o.length;p++)l?(d[p]&&d[p].classList.contains("e-disable")&&d[p].classList.add("e-disable"),o[p].disabled=!0,i[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),o[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"),o[p].disabled=!1,i[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),o[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,o){for(var i=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++)o?(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<i.length;g++)t.getComponent(i[g],"dropdownlist").enabled=!o;for(g=0;g<n.length;g++)t.getComponent(n[g],"numerictextbox").enabled=!o;for(g=0;g<r.length;g++)t.getComponent(r[g],"textbox").enabled=!o;for(g=0;g<s.length;g++)t.getComponent(s[g],"datepicker").enabled=!o;for(g=0;g<a.length;g++)t.getComponent(a[g],"checkbox").disabled=!!o;for(g=0;g<u.length;g++)t.getComponent(u[g],"radio").disabled=!!o;for(g=0;g<d.length;g++)t.getComponent(d[g],"multiselect").enabled=!o},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,o=0;return e.forEach(function(i){o++,t+="{",void 0!==i.rules&&("or"===i.condition?(t+=' "$or":[',t=l.convertMongoQuery(i.rules,t)+"]"):(t+=' "$and":[',t=l.convertMongoQuery(i.rules,t)+"]"));var n="string"===i.type&&"in"!==i.operator&&"notin"!==i.operator&&i.value&&""!==i.value.trim()?i.value.replace(/'/g,"\\"):"";"string"!==i.type||"in"!==i.operator&&"notin"!==i.operator||!i.value||1!==i.value.length||(n=i.value[0].replace(/'/g,"\\"));var r=i.field?i.field.substring(0):"";switch(i.operator){case"contains":t+='"'+r+'":{"$regex":"'+n+'"}';break;case"notcontains":t+='"'+r+'":{"$not":{"$regex":"'+i.value+'"}}';break;case"startswith":t+='"'+r+'":{"$regex":"^'+n+'"}';break;case"notstartswith":t+='"'+r+'":{"$not":{"$regex":"^'+i.value+'"}}';break;case"endswith":t+='"'+r+'":{"$regex":"'+n+'$"}';break;case"notendswith":t+='"'+r+'":{"$not":{"$regex":"'+i.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"===i.type?t+='"'+r+'":"'+n+'"':"date"===i.type?t+='"'+r+'":"'+i.value+'"':(i.type,t+='"'+r+'":'+i.value);break;case"notequal":"string"===i.type?t+='"'+r+'":{"$ne":"'+n+'"}':"date"===i.type?t+='"'+r+'":{"$ne":"'+i.value+'"}':t+='"'+r+'":{"$ne":'+i.value+"}";break;case"in":"string"===i.type?i.value.length>1?(s=(s=i.value.map(function(e,t){return t<i.value.length?'"'+e+'"':""}).toString()).endsWith(",")?s.substring(0,s.length-1):s,t+='"'+r+'": { "$in": ['+s+"]}"):t+='"'+r+'": { "$in": ["'+n+'"]}':"number"===i.type&&(i.value.length>1?t+='"'+r+'": { "$in": ['+i.value.toString()+"]}":t+='"'+r+'": { "$in": ['+i.value+"]}");break;case"notin":if("string"===i.type)if(i.value.length>1){var s=i.value.map(function(e,t){return t<i.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"===i.type&&(i.value.length>1?t+='"'+r+'": { "$nin": ['+i.value.toString()+"]}":t+='"'+r+'": { "$nin": ['+i.value+"]}");break;case"greaterthan":"number"===i.type?t+='"'+r+'": { "$gt": '+i.value+"}":t+='"'+r+'": { "$gt": "'+i.value+'"}';break;case"greaterthanorequal":"number"===i.type?t+='"'+r+'": { "$gte": '+i.value+"}":t+='"'+r+'": { "$gte": "'+i.value+'"}';break;case"between":"number"===i.type?t+='"'+r+'": {"$gte":'+i.value[0]+', "$lte":'+i.value[1]+"}":t+='"'+r+'": {"$gte": "'+i.value[0]+'", "$lte": "'+i.value[1]+'"}';break;case"notbetween":"number"===i.type?t+='"$or":[{"'+r+'": {"$lt":'+i.value[0]+'}}, {"'+r+'": {"$gt":'+i.value[1]+"}}]":t+='"$or":[{"'+r+'": {"$lt": "'+i.value[0]+'"}}, {"'+r+'": {"$gt": "'+i.value[1]+'"}}]';break;case"lessthan":"number"===i.type?t+='"'+r+'": { "$lt": '+i.value+"}":t+='"'+r+'": { "$lt": "'+i.value+'"}';break;case"lessthanorequal":"number"===i.type?t+='"'+r+'": { "$lte": '+i.value+"}":t+='"'+r+'": { "$lte": "'+i.value+'"}'}t+="}",e.length!==o&&(t+=",")}),t},e.prototype.mongoParser=function(e,t,l){var o;Object.keys(e).indexOf("$and")>-1?(o=e.$and,t.condition="and"):Object.keys(e).indexOf("$or")>-1&&(o=e.$or,t.condition="or"),t.rules=[],this.mongoRecursion(o,t.rules,l)},e.prototype.mongoRecursion=function(e,l,o){for(var i,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,o);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&&(i="notbetween",c={field:C,label:C,value:m=[k=w[C][x],q[C][O]],operator:i,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,o))}else{if(null===(d=e[g][u])&&(i="isnull"),"boolean"==typeof d&&(i="equal",n="boolean",m=d),"number"==typeof d)m=d,n="number",i="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)&&(i="isnotnull",m=null),"$ne"===s&&"boolean"==typeof r&&(i="notequal",m=r,n="boolean"),h.length>=2&&h[N]?("object"==typeof r?(i="notbetween",u=Object.keys(r)[0],a=[Object.keys(r[u])[0]],v.push(r[u][a]),n="number"):(i="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?(i="notstartswith",m=r.$regex.replace("^","")):r.$regex.indexOf("$")>-1?(i="notendswith",m=r.$regex.replace("$","")):(i="notcontains",m=r.$regex):(i="$in"===s?"in":"notin",y=r,n="number"==typeof r[0]?"number":"string"):"number"==typeof r&&(i=this.getOperatorFromMongoOperator(s),n="number",m=r),"string"==typeof r&&("$regex"===s&&(i="contains",m=r,n="string"),"$ne"===s&&(null!==r&&r.length>0&&isNaN(Date.parse(r))?(i="notequal",m=r):t.isNullOrUndefined(r)?(i="isnotnull",m=r):""===r&&(i="isnotempty",m=r),n="string"),r.indexOf("^")>-1&&(i="startswith",m=r.replace("^",""),n="string"),r.indexOf("$")>-1&&"$not"!==s&&(i="endswith",m=r.replace("$",""),n="string"),isNaN(Date.parse(r))||(i=i||this.getOperatorFromMongoOperator(s),n="date",m=r))}else d&&"string"==typeof d&&!isNaN(Date.parse(d))?(i="equal",m=d,n="date"):"string"==typeof d&&""!==d&&"true"!==d&&"false"!==d?(i="equal",m=d,n="string"):"string"==typeof d&&""===d&&(i="isempty",m=d,n="string");c=v&&v.length>1?{field:u,label:u,value:v,operator:i,type:n}:y&&y.length>1?{field:u,label:u,value:y,operator:i,type:n}:{field:u,label:u,value:m,operator:i,type:n},l.push(c),i=""}}},e.prototype.convertParamSqlToSql=function(e){for(var t=e.sql,l=e.params,o=t.split("?"),i=o[0],n=0;n<l.length;n++)i+="string"==typeof l[n]?"'"+l[n]+"'"+o[n+1]:l[n]+o[n+1];return 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.convertNamedParamSqlToSql=function(e){var t=e.sql,l=e.params,o=t;return Object.keys(l).forEach(function(e){var t=l[e];e=":"+e,o=o.replace(e,"string"==typeof t?"'"+t+"'":String(t))}),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.getParameterSql=function(e){var l=t.extend({},e,null,!0),o=this.updateRuleValue(l,!1);return this.getParameterSQLVal(this.parent.getSqlFromRules(l),o.ruleVal)},e.prototype.getNamedParameterSql=function(e){var l=t.extend({},e,null,!0),o=this.updateRuleValue(l,!0);return this.getNamedParameterSQLVal(this.parent.getSqlFromRules(l),o.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=[],o={},i=[];return this.updateValue(e.rules,t,l,o,i)},e.prototype.updateValue=function(e,l,o,i,n){if(t.isNullOrUndefined(e))return{ruleVal:o,namedRuleVal:i};for(var r=0;r<e.length;r++)if(e[r].rules)o=(u=this.updateValue(e[r].rules,l,o,i,n)).ruleVal,i=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?i[s]=e[r].value[a]:o.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?i[s]=u:o.push(u)}else l?i[s]="":o.push(""),"isempty"===e[r].operator?e[r].operator="equal":e[r].operator="notequal";else t.isNullOrUndefined(e[r].value)||(l?i[s]=e[r].value:o.push(e[r].value));e[r].value=l?":"+s:"?"}}return{ruleVal:o,namedRuleVal:i}},e.prototype.getNamedParameter=function(e,t){var l=null;if(t.length>0)for(var o=t.length-1;o>=0;o--){var i=t[o];if(i.indexOf(e)>-1){l=e+"_"+(parseInt(i.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,o,i,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 o(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(o.prototype=l.prototype,new o)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,o=arguments.length;l<o;l++){t=arguments[l];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)},p=function(e,t,l,o){var i,n=arguments.length,r=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,l):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,l,o);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(r=(n<3?i(r):n>3?i(t,l,r):i(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(!1)],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 i=e.call(this,t,l)||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,o.MultiSelect.Inject(o.CheckBoxSelection),i}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"),o=0,i=l.length;o<i;o++)l[o].className.indexOf("e-tooltip")>-1?t.getComponent(l[o],"tooltip").destroy():l[o].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[o].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=[],o=void 0,i=!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"===(o=typeof(r=this.dataColl[0][d[a].field]))?n=!isNaN(Date.parse(r)):"object"===o&&(n=r instanceof Date&&!isNaN(r.getTime()),o="string"),d[a].type=o,n=!1),o="string"),d[a].validation||(d[a].validation=s),d[a].category?i=!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"]);i&&(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"===(o=typeof(r=this.dataColl[0][e[a]]))?n=!isNaN(Date.parse(r)):"object"!==o||Object.keys(r).length||(n=r instanceof Date&&!isNaN(r.getTime()),o="string"),t[a]={field:e[a],label:e[a],type:n?"date":o,validation:s},n=!1,t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===o&&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 o;t.columns=[];var i,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]];i=typeof n,o={field:t.field+this.separator+r[s],label:r[s],type:i="object"!==i||isNaN(Date.parse(n))?i:"date"},"object"!==i&&(o.operators=this.customOperators[i+"Operator"]),t.columns.push(o),"object"===i&&this.updateSubFields(n,o,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 o=this,i=0;i<e.operators.length;i++)!function(t){var l=Object.keys(e.operators[t]).indexOf("sqlOperator");if(l>-1){var i=e.operators[t],n=Object.keys(i),r=n.map(function(e){return i[""+e]}).join(",").split(","),s=n.indexOf("value");o.operators[r[s]]=r[l]}}(i)}},c.prototype.focusEventHandler=function(e){this.target=e.target},c.prototype.clickEventHandler=function(e){var l,o=this,i=e.target;this.isImportRules=!1;var n;if("SPAN"===i.tagName&&(i=i.parentElement),i.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"===i.tagName&&i.className.indexOf("e-qb-toggle")<0)switch(!0){case i.className.indexOf("e-removerule")>-1:this.actionButton=i,this.deleteRule(i);break;case i.className.indexOf("e-clone-rule-btn")>-1:this.actionButton=i,this.cloneRuleBtnClick=!0,this.ruleClone(i);break;case i.className.indexOf("e-lock-rule-btn")>-1:this.actionButton=i,this.ruleLock(i);break;case i.className.indexOf("e-lock-grp-btn")>-1:this.actionButton=i,this.groupLock(i);break;case i.className.indexOf("e-clone-grp-btn")>-1:this.actionButton=i,this.cloneGrpBtnClick=!0,this.groupClone(t.closest(i,".e-group-container"));break;case i.className.indexOf("e-deletegroup")>-1:this.actionButton=i,this.deleteGroup(t.closest(i,".e-group-container"));break;case i.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"===i.tagName&&i.parentElement.className.indexOf("e-btn-group")>-1||i.className.indexOf("e-qb-toggle")>-1){var p=t.closest(i,".e-group-container");if(!this.headerTemplate){var c=i.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(i.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,i):this.trigger("beforeChange",l,function(e){o.beforeSuccessCallBack(e,i)}),this.target=i}},c.prototype.beforeSuccessCallBack=function(e,l){if(!e.cancel){var o=t.closest(l,".e-group-container"),i=o.id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),r=this.getParentGroup(o);r.condition=e.value,this.enableNotCondition&&(r.not=e.not),this.isImportRules||this.trigger("change",{groupID:i,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,o,i,n,r){var s,a,u,d=e.querySelector(".e-rule-list");if("change"===o?s=t.select("#"+i,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,o,i,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,o,i,n)):this.trigger("beforeChange",s,function(s){r.addRuleSuccessCallBack(s,e,t,l,o,i,n)})}},c.prototype.addRuleSuccessCallBack=function(e,l,i,n,r,s,a){var u,p,c,h,m=this.element.className.indexOf("e-device")>-1?"250px":"200px",g=i&&i.field?this.getColumn(i.field):n||this.columns[0],f={label:"",field:"",type:"",operator:""};if(!e.cancel){if(g&&g.ruleTemplate&&i.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(i).length?i: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,i,f,a,s),!g||g&&!g.ruleTemplate||!i.field)if("Default"===this.fieldMode){var S=void 0,x=void 0;x=this.separator&&i.field?this.GetRootColumnName(i.field):this.autoSelectField?this.GetRootColumnName(i.field):this.isImportRules?this.GetRootColumnName(i.field):i.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:i?x:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(S=d({},S,this.fieldModel)),(c=new o.DropDownList(S)).appendTo("#"+h.id+"_filterkey");w=void 0;w=this.separator&&i.field?this.GetRootColumnName(i.field):this.isImportRules?this.GetRootColumnName(i.field):c.value,this.selectedColumn=c.getDataByValue(w),Object.keys(i).length&&this.changeRule(i,{element:c.element,itemData:this.selectedColumn})}else{var S=void 0,x=(this.isImportRules,i.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 o.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(i.field)?O.value:this.GetRootColumnName(i.field);this.selectedColumn=this.getColumn(w),Object.keys(i).length&&this.changeRule(i,{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,o,i,n){var r,s,a,u=0;if(i){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&&(o.custom=d),this.autoSelectField&&(l.field=o.field=this.rule.rules[0].field),a.rules.push(o))}this.disableRuleCondition(e,a)},c.prototype.changeRuleTemplate=function(e,l){var o=this.selectedColumn.operators;if(!e.ruleTemplate){var i=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:o[0].value,value:""};this.addRuleElement(i,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 o=["isnull","isnotnull","isempty","isnotempty"],i=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(i=0,n=m.length;i<n;i++){var g=void 0;if(u=t.closest(m[i],".e-group-container"),h=this.getParentGroup(u),d=0,s=c=m[i],"DropdownTree"===this.fieldMode?(e=t.getComponent(m[i].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[i].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),o.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,o,i=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,r=i.length,s=0;for(o=0;o<r;o++)(l=i[o]).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,o,i,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),o=this.createElement("div",{attrs:{class:"e-group-action"}}),i=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),o.appendChild(i),r.appendChild(o)),n},c.prototype.ruleTemplate=function(){var e,l,o,i,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"}}),o=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",i=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:o}}),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:i}});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,o,i,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,o,i,n,r)):this.trigger("beforeChange",a,function(a){s.addGroupSuccess(a,e,t,l,o,i,n,r)})},c.prototype.addGroupSuccess=function(e,o,i,n,r,a,u,d){if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var p=i,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?(o=!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(o){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,o,i,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:o,rule:this.getRuleCollection(i,!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,o){var i=t.closest(l,".e-group-container"),n=this.getParentGroup(i),r=t.closest(l,".e-rule-container"),s=0;if("not"===o)return void(n.not=e);if("condition"===o)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,o):(this.isNotified=!0,this.updateRules(l,e),this.isNotified=!1)},c.prototype.templateChange=function(e,l,o){var i,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"===o?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(o){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),o),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===o||"operator"===o)){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,o,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:o,ruleID:m.id,fields:this.fields,rule:u};i={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",i)}},c.prototype.changeValue=function(e,l){var o,i=this;if(this.isNumInput&&"number"==typeof l.value)return void(this.isNumInput=!1);((o=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||o.className.indexOf("e-today")>-1||o.className.indexOf("e-cell")>-1)&&(o=l.element);var r,s=t.closest(o,".e-group-container"),a=t.closest(o,".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&&(o=p.element,(r=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"))&&(this.selectedColumn=r.getDataByValue(r.value)),(r=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"))&&(this.selectedColumn=this.getColumn(r.value[0])));var c,h;o.className.indexOf("e-radio")>-1?(h=parseInt(o.id.split("valuekey")[1],0),"Default"===this.fieldMode?(r=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=r.getDataByValue(r.value),this.selectedColumn.columns&&(r=t.getComponent(t.closest(o,".e-rule-container").querySelector(".e-rule-sub-filter .e-dropdownlist"),"dropdownlist"),this.selectedColumn=this.getColumn(r.value))):(r=t.getComponent(t.closest(o,".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]):o.className.indexOf("e-multiselect")>-1?c=t.getComponent(o,"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(){i.filterValue(u,d,c,e,o)},this.immediateModeDelay)):this.filterValue(u,d,c,e,o)},c.prototype.filterValue=function(e,t,l,o,i){var n=this,r={groupID:e,ruleID:t,value:l,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(r,i,o,e,t):this.trigger("beforeChange",r,function(l){n.changeValueSuccessCallBack(l,i,o,e,t)})},c.prototype.changeValueSuccessCallBack=function(e,t,l,o,i){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules||this.trigger("change",{groupID:o,ruleID:i,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"),o=l.popupObj.element.querySelector(".e-active"),i=l.getItemData();l.value=i.value;var n={element:l.element,value:i.value,isInteracted:!0,previousItemData:this.prevItemData,previousItem:null,item:o,itemData:i,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"),o="DropdownTree"===this.fieldMode?this.getColumn(e.value[0]):this.getColumn(e.value);if("DropdownTree"===this.fieldMode&&null!==l){var i=l.querySelector(".e-dropdowntree.e-control"),n=t.getComponent(i,"dropdowntree");if(!o)return;if("object"===o.type){if(n.value=e.oldValue,n.dataBind(),t.isNullOrUndefined(e.oldValue))i.value="";else{r=this.getLabelFromColumn(e.oldValue[0]);i.value=r}return}if(!t.isNullOrUndefined(e.value[0])){n.value=e.value[0],n.dataBind();var r=this.getLabelFromColumn(e.value[0]);i.value=r}}if(this.destroySubFields(l),this.subFieldElem=null,this.isNotValueChange=!0,o&&o.ruleTemplate)this.templateChange(e.element,o.field,"field");else if(o&&o.columns&&o.columns[0].ruleTemplate)this.templateChange(e.element,o.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 o={},i=t.closest(l.element,".e-rule-filter");i=i||t.closest(l.element,".e-rule-sub-filter");var n=t.getComponent(l.element,"dropdownlist");"DropdownTree"===this.fieldMode&&null!==i&&(n=t.getComponent(l.element,"dropdowntree"));var r=t.closest(l.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(i,n,r,e,o,l)},c.prototype.changeFilter=function(e,l,o,i,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:o,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,i,r):this.trigger("beforeChange",u,function(t){s.fieldChangeSuccess(t,n,e,i,r)})}else{var d=t.closest(r.element,".e-rule-operator");this.changeOperator(e,d,l,o,i,n,r)}},c.prototype.changeOperator=function(e,l,o,i,n,r,s){var a,u=this;l?(a={groupID:i,ruleID:t.closest(l,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:o.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,o,i,n){for(var r=t.closest(o,".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(o,s,u,a,i,l,n);else{if(t.isNullOrUndefined(this.selectedColumn))return;if(l.type=this.selectedColumn.type,r.querySelector(".e-template")&&(i.value=""),"object"===this.selectedColumn.type&&"Default"===this.fieldMode)for(l.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(o,i,l,n);else this.destroySubFields(o),this.changeOperator(o,s,u,a,i,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,i,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 o.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,i,n)},c.prototype.operatorChangeSuccess=function(e,l,o,i,n){if(!e.cancel){var r=t.closest(n.element,".e-rule-operator"),s=r.nextElementSibling,a=t.getComponent(n.element,"dropdownlist"),u=i.operator?i.operator.toString().toLowerCase():"";o.operator=a.value.toString();var d=o.operator.toLowerCase();if(o.operator.toLowerCase().indexOf("between")>-1||o.operator.toLowerCase().indexOf("in")>-1&&o.operator.toLowerCase().indexOf("contains")<0?(l=r.previousElementSibling,o.type=i.type,(o.operator.toLowerCase().indexOf("in")<0||u.indexOf("in")<0)&&(i.value=[])):"object"==typeof i.value&&null!==i.value&&(i.value=i.value.length>0?i.value[0]:"number"===i.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,o.type=i.type)}if(u.indexOf("in")>-1&&u.indexOf("in")<5&&d.indexOf("in")>-1&&d.indexOf("in")<5&&(l=null),o.operator.indexOf("null")>-1||o.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(i.field).template&&(l=r.previousElementSibling),0==s.children.length&&(l=r.previousElementSibling),this.changeRuleValues(l,i,o,n)}},c.prototype.changeRuleValues=function(e,l,i,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")&&(i.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"),i.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"),i.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,i,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 o.DropDownList(v).appendTo("#"+h+"_operatorkey"),i.operator=l&&""!==l.operator&&!t.isNullOrUndefined(l.operator)?l.operator:s[0].value,this.isImportRules&&(i.type=this.selectedColumn.type,i.operator=l.operator),t.isNullOrUndefined(g)||""===g?this.autoSelectField&&this.autoSelectOperator&&this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,i,n.element):this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,i,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 o=l?e:e.nextElementSibling,i=o.querySelectorAll("input.e-control"),n=o.querySelectorAll("div.e-control:not(.e-handle)"),r=this.columns,s=0,a=i.length;s<a;s++){if(i[s].classList.contains("e-textbox"))t.getComponent(i[s],"textbox").destroy(),t.detach(t.select("input#"+i[s].id,o));else if(i[s].classList.contains("e-dropdownlist"))this.allowValidation&&i[s].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(i[s].parentElement,"tooltip").destroy(),t.getComponent(i[s],"dropdownlist").destroy();else if(i[s].classList.contains("e-radio"))t.getComponent(i[s],"radio").destroy();else if(i[s].classList.contains("e-numerictextbox"))t.getComponent(i[s],"numerictextbox").destroy(),t.detach(t.select("input#"+i[s].id,o));else if(i[s].classList.contains("e-datepicker"))t.getComponent(i[s],"datepicker").destroy();else if(i[s].classList.contains("e-multiselect"))t.getComponent(i[s],"multiselect").destroy();else if(i[s].className.indexOf("e-template")>-1)for(var u=i[s].className,d=0,p=r.length;d<p;d++)if(r[d].template&&u.indexOf(r[d].field)>-1){this.templateDestroy(r[d],i[s].id);break}document.getElementById(i[s].id)&&t.detach(i[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=o.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 o;if("string"!=typeof e.template||void 0===e.template.destroy){var i=(o=e.template).destroy;if(o.destroy){var n=void 0;document.getElementById(l)&&(n=t.closest(document.getElementById(l),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof i?(i=t.getValue(i,window))({field:e.field,elementId:l,elements:n}):o.destroy({field:e.field,elementId:l,elements:n})}}},c.prototype.getValues=function(e){var t,l={},o=[],i=[];this.separator.length>0&&(i=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(i.length>1)for(var u=n[r],d=void 0,p=0,c=i.length;p<c;p++)d=i[p],i.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,i.length>1?this.createNestedObject(a,i,t):a[""+e]=t,o.push(a))}return o},c.prototype.createNestedObject=function(e,t,l){for(var o,i=t.length-1,n=0;n<i;++n)(o=t[n])in e||(e[""+o]={}),e=e[""+o];e[t[i]]=l},c.prototype.getDistinctValues=function(e,t){for(var l={},o=[],i=[],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]:(i=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[i[i.length-1]]=n,o.push(d))}(a);return o},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 i.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 o.MultiSelect(p);c.appendTo("#"+t+"_valuekey"+l),this.updateRules(c.element,n,0)},c.prototype.multiSelectOpen=function(e,l){if(this.dataSource instanceof i.DataManager){var o=document.getElementById(e),n=t.getComponent(t.closest(o,".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(o,r))}},c.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},c.prototype.getMultiSelectData=function(e,l){var o,n=this,r=new i.Deferred,s=this.dataManager.executeQuery((new i.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(i){o=i.actual&&i.actual.result?i.actual.result:i.result,n.dataColl=t.extend(n.dataColl,o,[],!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 o=document.getElementById(l.popup.element.id.replace("_popup",""));if(o){var i=t.getComponent(o,"multiselect").value;this.updateRules(o,i,e)}},c.prototype.processTemplate=function(e,l,o,i){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:o,ruleID:n.id,operator:i.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:o.value,operator:i.operator,field:u.field,dataSource:u.values}):"function"!=typeof l.template&&l.template.write({elements:r.length>1?r:r[0],values:o.value,operator:i.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,o){var i=this.getItemData(e);if(t.isNullOrUndefined(i.value))return o?l?[0,0]:0:l?[]:"";if(l){if(!(i.value instanceof Array))return[i.value]}else if(i.value instanceof Array)return i.value[0];return i.value},c.prototype.renderStringValue=function(e,t,l,o,i){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,o)},this.valueModel&&this.valueModel.textBoxModel&&(p=d({},p,this.valueModel.textBoxModel));var c=new n.TextBox(p);c.appendTo("#"+e+"_valuekey"+o),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,o,r,a.values),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?i.style.width="100%":(i.style.width=null,i.style.minWidth="200px")},c.prototype.renderNumberValue=function(e,t,l,o,i,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,o)},this.valueModel&&this.valueModel.textBoxModel&&(h=d({},h,this.valueModel.textBoxModel));var m=new n.TextBox(h);m.appendTo("#"+e+"_valuekey"+o),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[o]?t.value[o]:this.setDefaultValue(e,!0,!0));var y=void 0;y={value:p instanceof Array?p[o]:p,format:v,min:g,max:f,width:"100%",step:r.step?r.step:1,change:this.changeValue.bind(this,o)},this.valueModel&&this.valueModel.numericTextBoxModel&&(y=d({},y,this.valueModel.numericTextBoxModel));var b=new n.NumericTextBox(y);b.appendTo("#"+e+"_valuekey"+o),b.element.setAttribute("aria-label",r.label+" Value"),b.element.oninput=this.changeValue.bind(this,o)}else p=this.isImportRules||this.ruleIndex>-1||this.groupIndex>-1?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,o,p,a.values),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null)},c.prototype.processValueString=function(e,t){var l=[],o=e.split(",");if("string"===t)return o;for(var i=0,n=o.length;i<n;i++)l.push(Number(o[i]));return l},c.prototype.parseDate=function(e,l){var o,i;if(l){var n=this.intl.getDateParser({skeleton:"full",type:"dateTime"});o=this.getFormat(l),i=n(e),t.isNullOrUndefined(i)&&(i=this.intl.parseDate(e,o))}else i=new Date(e);return i},c.prototype.renderControls=function(e,l,o,i,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,o,i);else{var s;s="boolean"===i.type?this.selectedColumn.values?this.selectedColumn.values.length:2:i.operator&&i.operator.toString().toLowerCase().indexOf("between")>-1?2:1;var a=t.closest(e,".e-rule-container").id,u=void 0,p=i.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(i.type){case"string":this.renderStringValue(a,o,p,c,u);break;case"number":this.renderNumberValue(a,o,p,c,u,l,s);break;case"boolean":this.processBoolValues(l,o,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(o.value&&!t.isNullOrUndefined(f)&&(m=s>1?o.value[c]:o.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&&o&&""!==o.field&&(f=(g=this.getColumn(o.field)).format),(this.isImportRules||this.isPublic||C)&&o&&(f=(g=this.getColumn(o.field)).format,o.value?(m=s>1?o.value[c]:o.value,h=this.parseDate(m,g.format)):h=o.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),!o.value){var x=document.getElementById(a+"_valuekey"+c);this.updateRules(x,h,null,this.isNotValueChange),this.isNotValueChange=!1}}}}},c.prototype.processBoolValues=function(e,o,i,n){var r,s,a=!1;t.isNullOrUndefined(o.type)&&e&&(o.type=e.type);var u;if(e.values){p=e.values;"boolean"!==o.type||t.isNullOrUndefined(o.value)?e.value?a=p[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toLowerCase()===o.value.toString().toLowerCase(),s=r=u=p[n]}else{var p=[!0,!1];"boolean"!==o.type||t.isNullOrUndefined(o.value)?e.value?a=p[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a="boolean"!=typeof o.value||!!o.value):a=p[n].toString().toLowerCase()===o.value.toString().toLowerCase(),"boolean"==typeof o.value&&1===n&&(a=!o.value),r=p[n].toString(),s=p[n],u=this.l10n.getConstant(["True","False"][n])}var c;c={label:u,name:i+"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("#"+i+"_valuekey"+n),a&&this.updateRules(h.element,s,0,!0)},c.prototype.getOperatorIndex=function(e,t){var l,o=e.dataSource.length;for(l=0;l<o;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,o,i,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");i&&(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(o=this.getPreviousItemData(o,d),o&&void 0===o.template?o.columns&&(o=this.getColumn(n.field)):"DropdownTree"===this.fieldMode&&void 0===o&&(o=this.getColumn(n.field)),o&&o.template){this.templateDestroy(o,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 o.template&&void 0!==o.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([m]),e.nextElementSibling.innerHTML="")}if(i&&(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,o,i,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:o,operator:i,rule:r,renderTemplate:!0},this.trigger("actionBegin",s,function(t){u=a.actionBeginSuccessCallBack(t,e,l,o,n)}),u;var d=void 0,p=e.template;if((d="string"==typeof p.create?t.getValue(p.create,window)({field:o,operator:i}):p.create({field:o,operator:i}))instanceof Element)d.id=l+"_valuekey0",t.addClass([d],"e-template"),n.nextElementSibling.appendChild(d),o.indexOf(" ")<0&&t.addClass([d],"e-"+o);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,o,i,n){if(e.renderTemplate){var r=void 0;this.columnTemplateFn=this.templateParser((l.template,l.template));var s=this.element.id+i;if(this.isReact)r=this.columnTemplateFn(e,this,o,s)[0],n.nextElementSibling.appendChild(r);else if(this.isAngular){var a=this.columnTemplateFn(e,this,o,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 o=1;e.className.indexOf("e-template")>-1&&(o=3);var i=e.className.split(" e-")[o],n=parseInt(e.id.slice(-1),2);switch(i){case"checkbox":var r=t.getComponent(e,i).value;l.value=""!==r?r:void 0;break;case"textbox":case"dropdownlist":l.value=t.getComponent(e,i).value;break;case"radio":var s=t.getComponent(e,i);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,i).value):l.value=t.getComponent(e,i).value;break;case"datepicker":var a=this.getColumn(l.field),u=this.getFormat(a.format),d=t.getComponent(e,i).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,i).value}},c.prototype.updateRules=function(e,l,o,i){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,o),i||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,o,i,n,r){var s,a,u=["in","between","notin","notbetween"];if(l.rules[o].operator&&(a=l.rules[o].operator.toString().toLowerCase()),null!==t){if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[o].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[o].value=t,s={groupID:i.id,ruleID:n.id,value:l.rules[o].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[o].value[r]=t:l.rules[o].value=t;else if(e.className.indexOf("e-radio")>-1)l.rules[o].value=t;else if(e.className.indexOf("e-multiselect")>-1)l.rules[o].value=t;else if(e.className.indexOf("e-textbox")>-1)"in"===a||"notin"===a?(l.rules[o].type,l.rules[o].value=this.processValueString(t,l.rules[o].type)):l.rules[o].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[o].value&&(l.rules[o].value=[]),l.rules[o].value[r]=this.intl.formatDate(t,m)):l.rules[o].value=this.intl.formatDate(t,m))}this.validateValue(l,n,o)}else e.className.indexOf("e-datepicker")>-1&&u.indexOf(a)>-1?("string"==typeof l.rules[o].value&&(l.rules[o].value=[]),l.rules[o].value[r]=t):l.rules[o].value=t},c.prototype.validateValue=function(e,l,o){t.isNullOrUndefined(o)||(e=e.rules[o]);var i="object"==typeof e.value;if(this.allowValidation&&(t.isNullOrUndefined(o)||(i?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 o=t.rules,i=[];if(!l){for(var n=0,r=o.length;n<r;n++)(t=o[n]).rules&&i.push(t);return i[e]}return t},c.prototype.destroy=function(){if(this.isDestroy=!0,this.element){var l,o,i,n;e.prototype.destroy.call(this);var r;for(i=(l=this.element.querySelectorAll(".e-addrulegroup")).length,o=0;o<i;o++)t.getComponent(l[o],"dropdown-btn").destroy(),t.detach(l[o]);for(n=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),o=0;o<n.length;o++)t.getComponent(n[o],"tooltip").destroy();for(i=(l=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,o=0;o<i;o++)t.getComponent(l[o],"dropdownlist")?t.getComponent(l[o],"dropdownlist").destroy():t.getComponent(l[o],"dropdowntree").destroy(),t.detach(l[o]);for(n=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),o=0;o<n.length;o++)t.getComponent(n[o],"tooltip").destroy();for(i=(l=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,o=0;o<i;o++)t.getComponent(l[o],"dropdownlist")&&(t.getComponent(l[o],"dropdownlist").destroy(),t.detach(l[o]));for(n=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),o=0;o<n.length;o++)t.getComponent(n[o],"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(o=0;o<r.length;o++)r[o].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,o=e.length;l<o;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),o=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var i=0,n=e.length;i<n;i++)this.updatedRule={isLocked:e[i].isLocked,condition:e[i].condition,not:e[i].not},this.importRules(e[i],l,!1,e[i].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?o.rules.push({condition:r,not:s,rules:[]}):o.rules.push({condition:r,rules:[]}):this.enableNotCondition?o.rules.splice(this.groupIndex+1,0,{condition:r,not:s,rules:[],isLocked:a}):o.rules.splice(this.groupIndex+1,0,{condition:r,rules:[],isLocked:a})}this.headerTemplate||this.disableRuleCondition(l,o)}},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"),o=void 0,i=0;i<l.length;i++)o=l.item(i),t.rippleEffect(o,{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"}}),o=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),o.appendChild(l),e.appendChild(o),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 i.DataManager(this.columns).executeLocal((new i.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new i.DataManager(this.columns).executeLocal((new i.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 o=0;o<e.rules.length;o++)l=e.rules[o],l=this.checkNotGroup(l),e.rules[o]=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 o=0,i=Object.keys(e);o<i.length;o++)switch(i[o]){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 i.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new i.Query).take(1))):(this.dataManager=new i.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new i.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),o=new i.Deferred;l.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){o.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],o=t?l.length-1:l.length,i=this.rule,n=0;n<o;n++)i=this.findGroupByIdx(l[n],i,0===n);return i},c.prototype.deleteGroup=function(e){var t,l=this,o=e;"string"==typeof e?(t=this.element.id+"_"+e,e=document.getElementById(t)):t=o.id.replace(this.element.id+"_","");var i={groupID:t,cancel:!1,type:"deleteGroup"};this.isImportRules?this.deleteGroupSuccessCallBack(i,e):this.trigger("beforeChange",i,function(t){l.deleteGroupSuccessCallBack(t,e)})},c.prototype.deleteGroupSuccessCallBack=function(e,l){if(!e.cancel){var o=l,i=this.getParentGroup(o,!0),n=0,r=void 0,s=void 0,a=this.getValidRules(this.rule),u=o.nextElementSibling,d=o.previousElementSibling,p=o.querySelectorAll(".e-group-container"),c=o.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!==o.previousElementSibling;)o=o.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=o.parentElement.parentElement.parentElement,m=[];if(this.isReact||this.isAngular){var g=i.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),i.rules.splice(n,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(h,i),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,o={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(o,e):this.trigger("beforeChange",o,function(t){l.deleteRuleSuccessCallBack(t,e)})},c.prototype.deleteRuleSuccessCallBack=function(e,l){if(!e.cancel){var o=t.closest(l,".e-group-container"),i=this.getParentGroup(o),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(i.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]),i.rules.splice(d,1),i.rules[0]&&i.rules[0].rules||this.disableRuleCondition(o,i);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,o=e.querySelector(".e-btngroup-and"),i=e.querySelector(".e-btngroup-or");l>1?(o.disabled=!1,i.disabled=!1,(i.nextElementSibling.classList.contains("e-btn-disable")||o.nextElementSibling.classList.contains("e-btn-disable"))&&(i.nextElementSibling.classList.remove("e-btn-disable"),o.nextElementSibling.classList.remove("e-btn-disable")),t&&"or"===t.condition?i.checked=!0:o.checked=!0):(o.checked=!1,o.disabled=!0,i.checked=!1,i.disabled=!0,t&&(i.nextElementSibling.classList.add("e-btn-disable"),o.nextElementSibling.classList.add("e-btn-disable")))}},c.prototype.getValidRules=function(e){e||(e=this.getRules());var l=e.condition,o=e.not,i=t.extend([],e.rules,[],!0);return this.getRuleCollection({condition:l,rules:i,not:o},!0)},c.prototype.getRuleCollection=function(e,l){if(t.isNullOrUndefined(e))return null;var o;if(e.rules&&e.rules.length&&(Object.keys(e.rules[0]).length>6||l))for(var i=e.rules.length,n=0;n<i;n++)o=e.rules[n],o=this.getRuleCollection(o,l),e.rules[n]=o,Object.keys(o).length<1&&l&&(e.rules.splice(n,1),n--,i--);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;e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value,isLocked:e.isLocked},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)t.isNullOrUndefined(e.condition)&&t.isNullOrUndefined(e.rules)?e={}:(e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not,isLocked:e.isLocked}:{condition:e.condition,rules:e.rules,isLocked:e.isLocked},r&&(e.custom=r),0===e.rules.length&&(e={}));else{var a=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=a)}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},this.rule.custom&&(e.custom=this.rule.custom),e},c.prototype.getRule=function(e){var l,o,i=0;if(e instanceof HTMLElement?l=t.closest(e,".e-rule-container"):(o=this.element.id+"_"+e,l=document.getElementById(o)),t.isNullOrUndefined(l))return null;for(var n=t.closest(l,".e-group-container"),r=this.getParentGroup(n);null!==l.previousElementSibling;)l=l.previousElementSibling,i++;return r.rules[i]},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,o=e.length;for(t=0;t<o;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 i.Query:(new i.Query).where(e);return this.dataManager.executeQuery(l)},c.prototype.deleteRules=function(e){var t,l,o=e.length;for(t=0;t<o;t++)l=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(l))},c.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],o=0,n=Object.keys(this.columns);o<n.length;o++)l.push(this.columns[o].field);return e.rules.length?(new i.Query).select(l).where(t):(new i.Query).select(l)},c.prototype.getPredicate=function(e){var l,o,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)(o=this.getPredicate(s[u]))&&(l=l?"and"===e.condition?l.and(o):l.or(o):o);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 i.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 i.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 i.Predicate(s[u].field,p,n,a))}}}return this.dataSource instanceof i.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,o=this.columns,i=0,n=(o=t||o).length;i<n;i++){if(o[i].field===e){l=o[i];break}if(o[i].columns){if(l=this.getColumn(e,o[i].columns))break}else if(e&&e.indexOf(this.separator)>-1&&""!==this.separator&&o[i].field===e.split(this.separator)[0]){l=o[i];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,o){var n,r=this.setTime(new Date(t.getTime()),!0),s=this.setTime(t);switch(e.operator){case"equal":n=(n=new i.Predicate(e.field,"greaterthanorequal",r)).and(e.field,"lessthanorequal",s);break;case"notequal":n=(n=new i.Predicate(e.field,"lessthan",r)).or(e.field,"greaterthan",s);break;case"greaterthan":n=new i.Predicate(e.field,"greaterthan",s);break;case"greaterthanorequal":n=new i.Predicate(e.field,"greaterthanorequal",r);break;case"lessthan":n=new i.Predicate(e.field,"lessthan",r);break;case"lessthanorequal":n=new i.Predicate(e.field,"lessthanorequal",s)}return n&&(l?"and"===o?l=l.and(n):"or"===o&&(l=l.or(n)):l=n),l},c.prototype.arrayPredicate=function(e,t,l){var o,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":o=new i.Predicate(e.field,"isnull",s);break;case"isnotnull":o=new i.Predicate(e.field,"isnotnull",s);break;case"isempty":o=new i.Predicate(e.field,"equal","");break;case"isnotempty":o=new i.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":o="date"!==a.type?new i.Predicate(e.field,c,n[d]):new i.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":o="date"===a.type?new i.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 i.Predicate(e.field,"lessthan",n[d]);break;case"in":o=new i.Predicate(e.field,"equal",n[d]);break;case"notin":o=new i.Predicate(e.field,"notequal",n[d])}}else{switch(e.operator){case"between":o="date"===a.type?o.and(e.field,"lessthanorequal",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u)):n[d]):o.and(e.field,"lessthanorequal",n[d]);break;case"notbetween":o="date"===a.type?o.or(e.field,"greaterthan",n[d]?this.isTime(n[d])?this.getDate(n[d],u):this.setTime(this.getDate(n[d],u)):n[d]):o.or(e.field,"greaterthan",n[d]);break;case"in":o=o.or(e.field,"equal",n[d]);break;case"notin":o=o.and(e.field,"notequal",n[d])}}return o&&(t?"and"===l?t=t.and(o):"or"===l&&(t=t.or(o)):t=o),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,o,i,n){if(o){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,i);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,o,i){this.addGroupElement(!0,l,t,!1,o,i,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"),i=0;i<e.length;i++)e[i].classList.contains("e-dropdownlist")?t.getInstance(e[i],o.DropDownList).readonly=this.isReadonly:e[i].classList.contains("e-dropdowntree")?t.getComponent(e[i],"dropdowntree").readonly=this.isReadonly:e[i].classList.contains("e-numerictextbox")?t.getInstance(e[i],n.NumericTextBox).readonly=this.isReadonly:e[i].classList.contains("e-textbox")?t.getInstance(e[i],n.TextBox).readonly=this.isReadonly:e[i].classList.contains("e-datepicker")?t.getInstance(e[i],r.DatePicker).readonly=this.isReadonly:e[i].classList.contains("e-multiselect")?t.getInstance(e[i],o.MultiSelect).readonly=this.isReadonly:e[i].classList.contains("e-radio")&&(t.getInstance(e[i],l.RadioButton).checked||(this.isReadonly?e[i].parentElement.style.display="none":e[i].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],i=0;i<d.length;i++)d[i].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,o=t.length;l<o;l++)if(e.toLowerCase().indexOf(t[l])>-1)return!0;return!1},c.prototype.getSqlString=function(e,t,l,o){var i=!1;l||""===l?l+="(":(l="",i=!0);var n=e.condition;if(e.not){l+=i?o?this.l10n.getConstant("NOT").toUpperCase()+" (":"NOT (":o?" "+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,o);else{var a=e.rules[r],u="",d=o?this.sqlOperators[a.operator]:this.operators[a.operator];if(a.value instanceof Array)if(a.operator.toString().indexOf("between")>-1){var p=o?" "+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=o?this.l10n.getConstant(n.toUpperCase()).toUpperCase():n.toUpperCase())+" "}}return i||(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 o=this.getRulesFromSql(l);this.setRules({condition:o.condition,not:o.not,rules:o.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 o=this.getRulesFromSql(l);this.setRules({condition:o.condition,not:o.not,rules:o.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 o=this.getRule(e.replace(this.element.id+"_","")),i=this.showButtons.cloneRule;t=t.replace(this.element.id+"_",""),this.ruleIndex=l,this.cloneRuleBtnClick=!0,this.showButtons.cloneRule=!0,this.addRules([{label:o.label,field:o.field,type:o.type,operator:o.operator,value:o.value}],t),this.ruleIndex=-1,this.cloneRuleBtnClick=!1,this.showButtons.cloneRule=i,i=!1},c.prototype.cloneGroup=function(e,t,l){t=t.replace(this.element.id+"_","");var o=this.getGroup(t),i=this.showButtons.cloneGroup;e=e.replace(this.element.id+"_",""),this.groupIndex=l,this.cloneGrpBtnClick=!0,this.showButtons.cloneGroup=!0,this.addGroups([{condition:o.condition,not:o.not,rules:o.rules}],e),this.groupIndex=-1,this.cloneGrpBtnClick=!1,this.showButtons.cloneGroup=i,i=!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,o=0;do{l=e.slice(o),o+=this.parseSqlStrings(l,t)}while(""!==l);return this.parser},c.prototype.parseSqlStrings=function(e,t){var l,o=["=","!=","<=",">=","<",">"];l=t?[this.l10n.getConstant("AND").toUpperCase(),this.l10n.getConstant("OR").toUpperCase(),this.l10n.getConstant("NOT").toUpperCase()]:["AND","OR","NOT"];var i;i=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=o.length;s<a;s++)if(n=/^\w+$/.test(o[s])?"\\b":"",new RegExp("^("+o[s]+")"+n,"ig").exec(e))return this.parser.push(["Operators",o[s].toLowerCase()]),o[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=i.length;s<a;s++)if(n=/^\w+$/.test(i[s])?"\\b":"",new RegExp("^("+i[s]+")"+n,"ig").exec(e))return this.parser.push(["SubOperators",i[s].toLowerCase()]),i[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 o=e.replace(l,"");t.isNullOrUndefined(/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(o))&&(l+=/^((?:[^\\']+?|\\.|'')*)'(?!')/.exec(o)[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 o=this.parser[this.parser.length-2],i=this.parser[this.parser.length-3];if("Left"===l[0]&&o&&"Conditions"===o[0])return!0;var n=t?this.l10n.getConstant("Between").toLowerCase():"between";if("Conditions"===l[0]&&i&&i[1].indexOf(n)<0)return!0}return!1},c.prototype.getOperator=function(e,t,l){var o={"=":"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 i=Object.keys(this.sqlOperators),n=0;n<i.length;n++)if(this.sqlOperators[i[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":i[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 o[""+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 o=e.split(this.separator),i=0;i<o.length;i++)t+=this.getLabelFromField(o,i+1),++l<o.length&&(t+=this.separator);return t}return this.getColumn(e).label},c.prototype.getLabelFromField=function(e,t){for(var l="",o=0,i=0;i<t;i++)l+=e[i],++o<t&&(l+=this.separator);return this.getColumn(l).label},c.prototype.processParser=function(e,t,l,o){for(var i,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],o),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],o)}for(h=e[v+1][1],i=++v+1,n=y,o&&"contains"===r.operator||"startswith"===r.operator||"endswith"===r.operator?h="like":o&&"notcontains"===r.operator||"notstartswith"===r.operator||"notendswith"===r.operator?h="not like":o&&(h=r.operator),i=v+1;i<n;i++)if(h.indexOf("between")<0&&"Left"===e[i][0])f=!0;else{if("Right"===e[i][0]&&f){v=i,f=!1;break}if(h.indexOf("null")>-1||h.indexOf("empty")>-1)break;if(h.indexOf("like")>-1&&"String"===e[i][0]){S=e[i][1];e[i][1]&&"'"===e[i][1][0]&&(S=e[i][1].substring(1,e[i][1].length-1)),S=S?S.replace(/%/g,""):e[i][1],r.value=S,r.type="string"}else if(h.indexOf("between")>-1){if("Literal"===e[i][0]||"Left"===e[i][0])break;if("Number"===e[i][0])m.push(Number(e[i][1]));else if("String"===e[i][0]){S=e[i][1];e[i][1]&&"'"===e[i][1][0]&&(S=e[i][1].substring(1,e[i][1].length-1)),g.push(S)}}else if("Number"===e[i][0])m.push(Number(e[i][1]));else if("String"===e[i][0]){var S=e[i][1];e[i][1]&&"'"===e[i][1][0]&&(S=e[i][1].substring(1,e[i][1].length-1)),g.push(S)}r.type=this.getTypeFromColumn(r)}h.indexOf("like")<0&&("Number"===e[i-1][0]?(r.value=m,r.type="number"):"String"===e[i-1][0]?(r.value=g,r.type="string"):h.indexOf("between")>-1&&"Conditions"===e[i-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],o),"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]||o&&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,o),t}if("Conditions"===e[v][0])"not"===e[v][1]||o&&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,o)}}return t},c.prototype.getValueFromParser=function(e,t){var l,o="";for(l=t;l<e.length&&("String"===e[l][0]&&","!==e[l][1]&&", "!==e[l][1]);l++)""!==o&&(t+=1),null!==e[l][1]?o+=e[l][1]:o=null;return{value:o,idx:t}},c.prototype.groupClone=function(e){var t,l,o=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=o.id.replace(this.element.id+"_",""));var i=this.getGroup(t);this.groupIndex=Array.prototype.indexOf.call(e.closest(".e-rule-list").children,e.closest(".e-group-container")),this.addGroups([{condition:i.condition,not:i.not,rules:i.rules}],l),this.groupIndex=-1},c.prototype.ruleClone=function(e){for(var l=t.closest(e,".e-rule-container"),o=e.closest(".e-rule-list").closest(".e-group-container"),i=this.getRule(e),n=o.id.replace(this.element.id+"_",""),r=o.querySelectorAll(".e-rule-container"),s=0,a=r.length;s<a;s++)l.id===r[s].id&&(this.ruleIndex=s);this.addRules([{label:i.label,field:i.field,type:i.type,operator:i.operator,value:i.value}],n),this.ruleIndex=-1},c.prototype.ruleLock=function(e){var l=t.closest(e,".e-rule-container"),o=this.getRule(l.id.replace(this.element.id+"_",""));l.classList.contains("e-disable")?(o.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"))):(o.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"),o=this.getGroup(l.id.replace(this.element.id+"_","")),i=l.id.indexOf("group0")>-1;if(l.classList.contains("e-disable"))i?((n={}).condition=o.condition,n.not=o.not,n.isLocked=!1,this.setProperties({rule:n},!0)):o.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(i){var n={};n.condition=o.condition,n.not=o.not,n.isLocked=!0,this.setProperties({rule:n},!0)}else o.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]),o=l.querySelector(".e-lock-rule-btn");(l=t.closest(o,".e-rule-container")).classList.contains("e-disable")||this.ruleLock(o)}else{var i=this.element.querySelector("#"+this.lockItems[e]),o=i.querySelector(".e-lock-grp-btn");(i=t.closest(o,".e-group-container")).classList.contains("e-disable")||this.groupLock(o)}},c.prototype.disableHeaderControls=function(e,t,l){for(var o=t.querySelectorAll(".e-btngroup-and"),i=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<o.length;p++)l?(d[p]&&d[p].classList.contains("e-disable")&&d[p].classList.add("e-disable"),o[p].disabled=!0,i[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),o[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"),o[p].disabled=!1,i[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),o[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,o){for(var i=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++)o?(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<i.length;g++)t.getComponent(i[g],"dropdownlist").enabled=!o;for(g=0;g<n.length;g++)t.getComponent(n[g],"numerictextbox").enabled=!o;for(g=0;g<r.length;g++)t.getComponent(r[g],"textbox").enabled=!o;for(g=0;g<s.length;g++)t.getComponent(s[g],"datepicker").enabled=!o;for(g=0;g<a.length;g++)t.getComponent(a[g],"checkbox").disabled=!!o;for(g=0;g<u.length;g++)t.getComponent(u[g],"radio").disabled=!!o;for(g=0;g<d.length;g++)t.getComponent(d[g],"multiselect").enabled=!o},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,o=0;return e.forEach(function(i){o++,t+="{",void 0!==i.rules&&("or"===i.condition?(t+=' "$or":[',t=l.convertMongoQuery(i.rules,t)+"]"):(t+=' "$and":[',t=l.convertMongoQuery(i.rules,t)+"]"));var n="string"===i.type&&"in"!==i.operator&&"notin"!==i.operator&&i.value&&""!==i.value.trim()?i.value.replace(/'/g,"\\"):"";"string"!==i.type||"in"!==i.operator&&"notin"!==i.operator||!i.value||1!==i.value.length||(n=i.value[0].replace(/'/g,"\\"));var r=i.field?i.field.substring(0):"";switch(i.operator){case"contains":t+='"'+r+'":{"$regex":"'+n+'"}';break;case"notcontains":t+='"'+r+'":{"$not":{"$regex":"'+i.value+'"}}';break;case"startswith":t+='"'+r+'":{"$regex":"^'+n+'"}';break;case"notstartswith":t+='"'+r+'":{"$not":{"$regex":"^'+i.value+'"}}';break;case"endswith":t+='"'+r+'":{"$regex":"'+n+'$"}';break;case"notendswith":t+='"'+r+'":{"$not":{"$regex":"'+i.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"===i.type?t+='"'+r+'":"'+n+'"':"date"===i.type?t+='"'+r+'":"'+i.value+'"':(i.type,t+='"'+r+'":'+i.value);break;case"notequal":"string"===i.type?t+='"'+r+'":{"$ne":"'+n+'"}':"date"===i.type?t+='"'+r+'":{"$ne":"'+i.value+'"}':t+='"'+r+'":{"$ne":'+i.value+"}";break;case"in":"string"===i.type?i.value.length>1?(s=(s=i.value.map(function(e,t){return t<i.value.length?'"'+e+'"':""}).toString()).endsWith(",")?s.substring(0,s.length-1):s,t+='"'+r+'": { "$in": ['+s+"]}"):t+='"'+r+'": { "$in": ["'+n+'"]}':"number"===i.type&&(i.value.length>1?t+='"'+r+'": { "$in": ['+i.value.toString()+"]}":t+='"'+r+'": { "$in": ['+i.value+"]}");break;case"notin":if("string"===i.type)if(i.value.length>1){var s=i.value.map(function(e,t){return t<i.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"===i.type&&(i.value.length>1?t+='"'+r+'": { "$nin": ['+i.value.toString()+"]}":t+='"'+r+'": { "$nin": ['+i.value+"]}");break;case"greaterthan":"number"===i.type?t+='"'+r+'": { "$gt": '+i.value+"}":t+='"'+r+'": { "$gt": "'+i.value+'"}';break;case"greaterthanorequal":"number"===i.type?t+='"'+r+'": { "$gte": '+i.value+"}":t+='"'+r+'": { "$gte": "'+i.value+'"}';break;case"between":"number"===i.type?t+='"'+r+'": {"$gte":'+i.value[0]+', "$lte":'+i.value[1]+"}":t+='"'+r+'": {"$gte": "'+i.value[0]+'", "$lte": "'+i.value[1]+'"}';break;case"notbetween":"number"===i.type?t+='"$or":[{"'+r+'": {"$lt":'+i.value[0]+'}}, {"'+r+'": {"$gt":'+i.value[1]+"}}]":t+='"$or":[{"'+r+'": {"$lt": "'+i.value[0]+'"}}, {"'+r+'": {"$gt": "'+i.value[1]+'"}}]';break;case"lessthan":"number"===i.type?t+='"'+r+'": { "$lt": '+i.value+"}":t+='"'+r+'": { "$lt": "'+i.value+'"}';break;case"lessthanorequal":"number"===i.type?t+='"'+r+'": { "$lte": '+i.value+"}":t+='"'+r+'": { "$lte": "'+i.value+'"}'}t+="}",e.length!==o&&(t+=",")}),t},e.prototype.mongoParser=function(e,t,l){var o;Object.keys(e).indexOf("$and")>-1?(o=e.$and,t.condition="and"):Object.keys(e).indexOf("$or")>-1&&(o=e.$or,t.condition="or"),t.rules=[],this.mongoRecursion(o,t.rules,l)},e.prototype.mongoRecursion=function(e,l,o){for(var i,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,o);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&&(i="notbetween",c={field:C,label:C,value:m=[k=w[C][x],q[C][O]],operator:i,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,o))}else{if(null===(d=e[g][u])&&(i="isnull"),"boolean"==typeof d&&(i="equal",n="boolean",m=d),"number"==typeof d)m=d,n="number",i="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)&&(i="isnotnull",m=null),"$ne"===s&&"boolean"==typeof r&&(i="notequal",m=r,n="boolean"),h.length>=2&&h[N]?("object"==typeof r?(i="notbetween",u=Object.keys(r)[0],a=[Object.keys(r[u])[0]],v.push(r[u][a]),n="number"):(i="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?(i="notstartswith",m=r.$regex.replace("^","")):r.$regex.indexOf("$")>-1?(i="notendswith",m=r.$regex.replace("$","")):(i="notcontains",m=r.$regex):(i="$in"===s?"in":"notin",y=r,n="number"==typeof r[0]?"number":"string"):"number"==typeof r&&(i=this.getOperatorFromMongoOperator(s),n="number",m=r),"string"==typeof r&&("$regex"===s&&(i="contains",m=r,n="string"),"$ne"===s&&(null!==r&&r.length>0&&isNaN(Date.parse(r))?(i="notequal",m=r):t.isNullOrUndefined(r)?(i="isnotnull",m=r):""===r&&(i="isnotempty",m=r),n="string"),r.indexOf("^")>-1&&(i="startswith",m=r.replace("^",""),n="string"),r.indexOf("$")>-1&&"$not"!==s&&(i="endswith",m=r.replace("$",""),n="string"),isNaN(Date.parse(r))||(i=i||this.getOperatorFromMongoOperator(s),n="date",m=r))}else d&&"string"==typeof d&&!isNaN(Date.parse(d))?(i="equal",m=d,n="date"):"string"==typeof d&&""!==d&&"true"!==d&&"false"!==d?(i="equal",m=d,n="string"):"string"==typeof d&&""===d&&(i="isempty",m=d,n="string");c=v&&v.length>1?{field:u,label:u,value:v,operator:i,type:n}:y&&y.length>1?{field:u,label:u,value:y,operator:i,type:n}:{field:u,label:u,value:m,operator:i,type:n},l.push(c),i=""}}},e.prototype.convertParamSqlToSql=function(e){for(var t=e.sql,l=e.params,o=t.split("?"),i=o[0],n=0;n<l.length;n++)i+="string"==typeof l[n]?"'"+l[n]+"'"+o[n+1]:l[n]+o[n+1];return 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.convertNamedParamSqlToSql=function(e){var t=e.sql,l=e.params,o=t;return Object.keys(l).forEach(function(e){var t=l[e];e=":"+e,o=o.replace(e,"string"==typeof t?"'"+t+"'":String(t))}),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.getParameterSql=function(e){var l=t.extend({},e,null,!0),o=this.updateRuleValue(l,!1);return this.getParameterSQLVal(this.parent.getSqlFromRules(l),o.ruleVal)},e.prototype.getNamedParameterSql=function(e){var l=t.extend({},e,null,!0),o=this.updateRuleValue(l,!0);return this.getNamedParameterSQLVal(this.parent.getSqlFromRules(l),o.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=[],o={},i=[];return this.updateValue(e.rules,t,l,o,i)},e.prototype.updateValue=function(e,l,o,i,n){if(t.isNullOrUndefined(e))return{ruleVal:o,namedRuleVal:i};for(var r=0;r<e.length;r++)if(e[r].rules)o=(u=this.updateValue(e[r].rules,l,o,i,n)).ruleVal,i=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?i[s]=e[r].value[a]:o.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?i[s]=u:o.push(u)}else l?i[s]="":o.push(""),"isempty"===e[r].operator?e[r].operator="equal":e[r].operator="notequal";else t.isNullOrUndefined(e[r].value)||(l?i[s]=e[r].value:o.push(e[r].value));e[r].value=l?":"+s:"?"}}return{ruleVal:o,namedRuleVal:i}},e.prototype.getNamedParameter=function(e,t){var l=null;if(t.length>0)for(var o=t.length-1;o>=0;o--){var i=t[o];if(i.indexOf(e)>-1){l=e+"_"+(parseInt(i.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;
11
11
  //# sourceMappingURL=ej2-querybuilder.min.js.map