New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@syncfusion/ej2-querybuilder

Package Overview
Dependencies
Maintainers
2
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syncfusion/ej2-querybuilder - npm Package Compare versions

Comparing version 17.1.1-beta to 17.1.32-beta

styles/query-builder/_bootstrap4-definition.scss

41

CHANGELOG.md

@@ -5,2 +5,43 @@ # Changelog

### QueryBuilder
#### Breaking Changes
- The following events are renamed.
| Existing Event Name| New Event Name |
|------|-------------|
|beforeConditionChange|beforeChange|
|beforeFieldChange|beforeChange|
|beforeOperatorChange|beforeChange|
|beforeValueChange|beforeChange|
|conditionChanged|change|
|fieldChanged|change|
|operatorChanged|change|
|valueChanged|change|
|groupDelete|change|
|groupInsert|change|
|ruleDelete|change|
|ruleInsert|change|
#### Bug Fixes
- Between Operator produces incorrect SQL is fixed.
## 16.4.54 (2019-02-19)
### QueryBuilder
#### Bug Fixes
- 'Add Group' option is not disabled while setting groupInsert as false is fixed.
## 16.4.52 (2019-02-05)
### QueryBuilder
#### New Features
- Provided `Summary view` support.
## 16.4.44 (2018-12-24)

@@ -7,0 +48,0 @@

4

dist/ej2-querybuilder.umd.min.js
/*!
* filename: ej2-querybuilder.umd.min.js
* version : 17.1.1-beta
* version : 17.1.32-beta
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.

@@ -10,3 +10,3 @@ * Use of this code is subject to the terms of our license.

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-buttons"),require("@syncfusion/ej2-dropdowns"),require("@syncfusion/ej2-data"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-calendars"),require("@syncfusion/ej2-splitbuttons"),require("@syncfusion/ej2-popups")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-buttons","@syncfusion/ej2-dropdowns","@syncfusion/ej2-data","@syncfusion/ej2-inputs","@syncfusion/ej2-calendars","@syncfusion/ej2-splitbuttons","@syncfusion/ej2-popups"],t):t(e.ej={},e.ej2Base,e.ej2Buttons,e.ej2Dropdowns,e.ej2Data,e.ej2Inputs,e.ej2Calendars,e.ej2Splitbuttons,e.ej2Popups)}(this,function(e,t,r,n,l,o,i,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),p=function(e,t,r,n){var l,o=arguments.length,i=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(l=e[s])&&(i=(o<3?l(i):o>3?l(t,r,i):l(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};n.MultiSelect.Inject(n.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(t,r){return e.call(this,t,r)||this}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataSource.length){var e=Object.keys(this.dataSource[0]),t=[],r=void 0,n=!1,l=void 0,o={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var i=this.columns,s=0,a=i.length;s<a;s++)i[s].type||(e.indexOf(i[s].field)>-1&&("string"===(r=typeof(l=this.dataSource[0][i[s].field]))?n=!isNaN(Date.parse(l)):"object"===r&&(n=l instanceof Date&&!isNaN(l.getTime()),r="string"),i[s].type=r,n=!1),r="string"),i[s].validation||(i[s].validation=o)}else{for(s=0,a=e.length;s<a;s++)"string"===(r=typeof(l=this.dataSource[0][e[s]]))?n=!isNaN(Date.parse(l)):"object"===r&&(n=l instanceof Date&&!isNaN(l.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:n?"date":r,validation:o},n=!1;this.columns=t}}},d.prototype.clickEventHandler=function(e){var r=e.target;if(this.isImportRules=!1,"SPAN"===r.tagName&&(r=r.parentElement),"BUTTON"===r.tagName){if(r.className.indexOf("e-removerule")>-1)r.className.indexOf("e-tooltip")>-1&&t.getComponent(r,"tooltip").destroy(),this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)t.getComponent(r,"tooltip").destroy(),this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if(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);var n=t.extend({},this.rule,{},!0);this.setGroupRules(n),this.renderSummaryCollapse()}else{(l=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),l.style.display="block"}else if(r.className.indexOf("e-collapse-rule")>-1){var l;(l=this.element.querySelector(".e-group-container")).style.display="none",this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),document.getElementById(this.element.id+"_summary_content").style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1){var o=t.closest(r,".e-group-container"),i={groupID:o.id,selectedItem:r,cancel:!1};this.trigger("beforeConditionChange",i);this.getGroup(o).condition=r.textContent.toLowerCase(),i={groupID:o.id,selectedItem:r},this.trigger("conditionChanged",i)}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var l=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?l.className="e-rule-container e-vertical-mode":l.className="e-rule-container e-horizontal-mode";var o,i,s,u,p,d,c=e.querySelector(".e-rule-list"),h=l.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)h.textContent=this.l10n.getConstant("Remove");else{t.addClass([h],"e-round"),t.addClass([h],"e-icon-btn");new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(h),h=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),l.querySelector("button").appendChild(h)}if(l.setAttribute("id",e.id+"_e_rule"+this.ruleIdCounter),this.ruleIdCounter++,l.querySelector(".e-filter-input").setAttribute("id",l.id+"_filterkey"),c.appendChild(l),l.previousElementSibling&&l.previousElementSibling.className.indexOf("e-rule-container")>-1&&(l.className.indexOf("e-joined-rule")<0&&(l.className+=" e-joined-rule"),l.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(l.previousElementSibling.className+=" e-prev-joined-rule")),l.previousElementSibling&&l.previousElementSibling.className.indexOf("e-group-container")>-1&&l.className.indexOf("e-separate-rule")<0&&(l.className+=" e-separate-rule"),d=this.element.className.indexOf("e-device")>-1?"250px":"200px",(p=new n.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?d:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+l.id+"_filterkey"),this.filterIndex=p.index,o=this.levelColl[e.id],!this.isImportRules){for(i=this.rule,s=0,u=o.length;s<u;s++)i=this.findGroupByIdx(o[s],i,0===s);Object.keys(r).length?i.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):i.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.columns[this.filterIndex]})},d.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),position:"BottomCenter",cssClass:"e-querybuilder-error"});t.appendTo(e),t.open(e)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,n=void 0,l=void 0,o=void 0,i=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,n=c.length;r<n;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,o=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,l=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,a++;if(l=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1),l=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1),d.rules[a].value instanceof Array&&(i=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&i.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,f=m.length;y<f;y++){var g=m[y],v=void 0;g.parentElement.className.indexOf("e-searcher")>-1?(v=t.closest(g,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(v):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(l.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(l.parentElement),e=!1)}return e},d.prototype.groupTemplate=function(){var e,t,r,n,l,o,i,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),n=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(n),e.appendChild(t),l=this.createElement("div",{attrs:{class:"e-btn-group"}}),(o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),l.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl"},innerHTML:"AND"}),l.appendChild(i),o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),l.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl"},innerHTML:"OR"}),l.appendChild(i),r.appendChild(l),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,n,l,o;return e=this.createElement("div"),l=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),l.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),o=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",n=this.createElement("button",{attrs:{class:o}}),r.appendChild(n),l.appendChild(r),e.appendChild(l),e},d.prototype.addGroupElement=function(e,n,l,o){if(!(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var i,u=this.groupElem.cloneNode(!0);u.setAttribute("id",this.element.id+"_e_group"+this.groupIdCounter),this.groupIdCounter++;var p=u.querySelector(".e-btngroup-and"),d=u.querySelector(".e-btngroup-or"),c=u.querySelector(".e-btngroup-and-lbl"),h=u.querySelector(".e-btngroup-or-lbl");if(p.setAttribute("id",this.element.id+"_and"+this.btnGroupId),d.setAttribute("id",this.element.id+"_or"+this.btnGroupId),p.setAttribute("name",this.element.id+"_and"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var m=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";i=this.createElement("button",{attrs:{class:m}});new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(i);new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(i),t.rippleEffect(i,{selector:".deletegroup"}),u.querySelector(".e-group-action").appendChild(i);var y=n.querySelector(".e-rule-list"),f=n.querySelectorAll(".e-group-container").length;y.appendChild(u);var g=this.levelColl[n.id].slice(0);g.push(f),this.levelColl[u.id]=g,this.isImportRules||(this.addGroups([],n.id),o&&this.addRuleElement(u,{}))}else n.appendChild(u),this.levelColl[u.id]=[0];u.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===l&&u.querySelector(".e-btngroup-or").setAttribute("checked","true");var v=u.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,v),select:this.selectBtn.bind(this,v)}).appendTo(v),t.rippleEffect(v,{selector:".e-round"})}},d.prototype.notifyChange=function(e,r){for(var n=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),l=[],o=0,i=n.length;o<i;o++)n[o].nextElementSibling&&n[o].nextElementSibling.className.indexOf("e-check")>-1&&l.push(n[o].textContent);this.updateRules(r,n.length>1?l:e)},d.prototype.changeValue=function(e,r){var n,l;if(r.event)l=r.event.target;else{l=r.element}if(l.className.indexOf("e-day")>-1){l=r.element}var o=t.closest(l,".e-group-container"),i=t.closest(l,".e-rule-container"),s=r;s.element&&s.element.className.indexOf("e-datepicker")>-1&&(l=s.element);var a;a=l.className.indexOf("e-radio")>-1?t.getComponent(l,"radio").label:l.className.indexOf("e-multiselect")>-1?t.getComponent(l,"multiselect").value:r.value,n={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("beforeValueChange",n),this.updateRules(l,a,e),n={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("valueChanged",n)},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),n=this.getGroup(r),l=t.closest(e.element,".e-rule-container"),o=0;l&&null!==l.previousElementSibling;)l=l.previousElementSibling,o++;this.changeRule(n.rules[o],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var l,o,i,s,a,u={},p=e.operator?e.operator.toLowerCase():"";i=t.closest(r.element,".e-rule-filter"),s=t.closest(r.element,".e-rule-operator");var d=t.getComponent(r.element,"dropdownlist"),c=t.closest(r.element,".e-group-container");if(i){var h=t.closest(i,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeFieldChange",m),u.type=this.columns[d.index].type,h.querySelector(".e-template")&&(e.value="")}if(s){h=t.closest(s,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeOperatorChange",m),u.operator=r.itemData.value;var y=u.operator.toLowerCase();if(u.operator.toLowerCase().indexOf("between")>-1||u.operator.toLowerCase().indexOf("in")>-1&&u.operator.toLowerCase().indexOf("contains")<0?(i=s.previousElementSibling,u.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var f=r.previousItemData.value.toLowerCase();(f.indexOf("between")>-1||f.indexOf("in")>-1&&f.indexOf("contains")<0)&&(i=s.previousElementSibling,u.type=e.type)}p.indexOf("in")>-1&&p.indexOf("in")<5&&y.indexOf("in")>-1&&y.indexOf("in")<5&&(i=null)}if(i)if(s=i.nextElementSibling,t.addClass([s],"e-operator"),s.childElementCount)l=t.getComponent(s.querySelector(".e-dropdownlist"),"dropdownlist"),u.operator=l.value,this.renderValues(s,r.itemData,r.previousItemData,!0,e,u,r.element);else{var g=t.closest(s,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:g+"_operatorkey"}}),s.appendChild(a),this.columns[d.index].operators?o=this.columns[d.index].operators:r.itemData&&(o=this.customOperators[this.columns[d.index].type+"Operator"]);var v=this.element.className.indexOf("e-device")>-1?"250px":"200px";new n.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?v:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+g+"_operatorkey"),u.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(u.type=this.columns[d.index].type,u.operator=e.operator),this.renderValues(s,this.columns[d.index],r.previousItemData,!1,e,u,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var n;n=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var l=this.columns,o=0,i=r.length;o<i;o++){if(r[o].classList.contains("e-textbox"))t.getComponent(r[o],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-dropdownlist"))t.getComponent(r[o],"dropdownlist").destroy();else if(r[o].classList.contains("e-radio"))t.getComponent(r[o],"radio").destroy();else if(r[o].classList.contains("e-numerictextbox"))t.getComponent(r[o],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-datepicker"))t.getComponent(r[o],"datepicker").destroy();else if(r[o].classList.contains("e-multiselect"))t.getComponent(r[o],"multiselect").destroy();else if(r[o].className.indexOf("e-template")>-1)for(var s=r[o].className,a=0,u=l.length;a<u;a++)if(l[a].template&&s.indexOf(l[a].field)>-1){this.templateDestroy(l[a],r[o].id);break}document.getElementById(r[o].id)&&t.detach(r[o])}for(o=0,i=n.length;o<i;o++){if(n[o].className.indexOf("e-template")>-1)for(s=n[o].className,a=0,u=l.length;a<u;a++)if(l[a].template&&s.indexOf(l[a].field)>-1){this.templateDestroy(l[a],n[o].id);break}t.detach(n[o])}},d.prototype.templateDestroy=function(e,r){var n=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof n?(n=t.getValue(n,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},n=[],l=0,o=e.length;l<o;l++){var i=e[l][t];Number(e[l][t])===e[l][t]&&e[l][t]%1!=0&&(i=e[l][t].toString());var s={};i in r||(r[i]=1,s[t]=i,n.push(s))}return n},d.prototype.renderMultiSelect=function(e,t,r,o){var i=this.getDistinctValues(this.dataSource,e.field);new n.MultiSelect({dataSource:new l.DataManager(i),query:new l.Query([e.field]),fields:{text:e.field,value:e.field},value:o,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.processTemplate=function(e,r,n,l){var o=t.closest(e,".e-rule-container").querySelectorAll(".e-template");o.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o[0],values:n.value,operator:l.operator}):r.template&&r.template.write&&r.template.write({elements:o[0],values:n.value,operator:l.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o,values:n.value,operator:l.operator}):r.template&&r.template.write&&r.template.write({elements:o,values:n.value,operator:l.operator})},d.prototype.renderStringValue=function(e,t,r,n,l){var i,s=this.isImportRules?t.value:"";if(("in"===r||"notin"===r)&&this.dataSource.length>0)i=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,n,i),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?l.style.width="100%":(l.style.width=null,l.style.minWidth="200px");else{"in"!==r&&"notin"!==r||(s=(i=this.isImportRules?t.value:[]).join(","));var a=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});a.appendTo("#"+e+"_valuekey"+n),a.value=s,a.dataBind()}},d.prototype.renderNumberValue=function(e,r,n,l,i,s,a){var u,p=this.isImportRules?r.value:0;if(("in"===n||"notin"===n)&&this.dataSource.length>0)u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,l,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null);else if("in"===n||"notin"===n){var d=(u=this.isImportRules?r.value:[]).join(","),c=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});c.appendTo("#"+e+"_valuekey"+l),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,f=s.format?s.format:"#";a>1&&r&&(p=r.value[l]?r.value[l]:0);new o.NumericTextBox({value:p,format:f,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,l)}).appendTo("#"+e+"_valuekey"+l)}},d.prototype.processValueString=function(e,t){var r=[],n=e.split(",");if("string"===t)return n;for(var l=0,o=n.length;l<o;l++)r.push(Number(n[l]));return r},d.prototype.renderControls=function(e,n,l,o){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),n.template)this.processTemplate(e,n,l,o);else{var s="boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;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"!==o.operator&&"notin"!==o.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(o.type){case"string":this.renderStringValue(a,l,o.operator,p,u);break;case"number":this.renderNumberValue(a,l,o.operator,p,u,n,s);break;case"boolean":var d=n.values&&n.values.length?n.values:["True","False"],c=!this.isImportRules||Boolean(l.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&l&&l.value){h=s>1?new Date(l.value[p]):new Date(l.value);var y=void 0,f=this.getColumn(l.field);m=s>1?l.value[p]:l.value,y={type:"dateTime",format:f.format||"MM/dd/yyyy"},h=this.intl.parseDate(m,y)}var g=n.format?n.format:"MM/dd/yyyy";new i.DatePicker({value:h,format:g,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,n,l,o,i,s){if(l){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value)}var u=t.closest(e,".e-rule-container").id;n&&n.template&&(this.templateDestroy(n,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),l&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;var c=void 0;if(r.template&&"string"==typeof r.template.create?c=t.getValue(r.template.create,window)():r.template&&r.template.create&&(c=r.template.create()),c instanceof Element)c.id=u+"_valuekey0",t.addClass([c],"e-template"),t.addClass([c],"e-"+r.field),e.nextElementSibling.appendChild(c);else if(c instanceof Array){t.addClass(c,"e-template");for(var h=0,m=c.length;h<m;h++)c[h].id=u+"_valuekey"+h,e.nextElementSibling.appendChild(c[h])}var y=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?y.style.width="100%":y.style.minWidth="200px"}else if("boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1)for(h=0;h<2;h++){c=void 0;c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+h}}),e.nextElementSibling.appendChild(c)}else{c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(c)}this.renderControls(e,r,o,i)},d.prototype.updateValues=function(e,r){var n=e.className.split(" e-")[1],l=parseInt(e.id.slice(-1),2);switch(n){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,n).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[l]=t.getComponent(e,n).value:r.value=t.getComponent(e,n).value;break;case"datepicker":var o={type:"dateTime",format:this.getColumn(r.field).format||"MM/dd/yyyy"};r.operator.indexOf("between")>-1?r.value[l]=t.getComponent(e,n).value:r.value=this.intl.formatDate(t.getComponent(e,n).value,o)}},d.prototype.updateRules=function(e,r,n){for(var l,o,i=t.closest(e,".e-group-container"),s=this.getGroup(i),a=t.closest(e,".e-rule-container"),u=0;a&&null!==a.previousElementSibling;)a=a.previousElementSibling,u++;if(a=t.closest(e,".e-rule-container"),t.closest(e,".e-rule-filter")){l=t.getComponent(e,"dropdownlist"),s.rules[u].field=this.columns[l.index].field,s.rules[u].type=this.columns[l.index].type,s.rules[u].label=this.columns[l.index].label;var p=t.closest(e,".e-rule-filter"),d=p.nextElementSibling.querySelector("input.e-control"),c=t.getComponent(d,"dropdownlist").value;s.rules[u].operator=c,(d=p.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(d=p.nextElementSibling.nextElementSibling.querySelector("div.e-control")),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.updateValues(d,s.rules[u]),this.trigger("fieldChanged",o),this.allowValidation&&s.rules[u].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){l=t.getComponent(e,"dropdownlist"),s.rules[u].operator=l.value;var h=void 0;e.parentElement;h=a.querySelectorAll(".e-rule-value input.e-control"),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.allowValidation&&s.rules[u].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),h.length>1&&(s.rules[u].value=[]);for(var m=0;m<h.length;m++)this.updateValues(h[m],s.rules[u]);this.trigger("operatorChanged",o)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,s,u,i,a,n)},d.prototype.ruleValueUpdate=function(e,r,l,o,i,s,a){var u,p=["in","between"];if(null!==r){var d=l.rules[o].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===l.rules[o].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?l.rules[o].value=r:l.rules[o].value=r[0]:l.rules[o].value=r,u={groupID:i.id,ruleID:s.id,selectedItem:r,cancel:!1},this.trigger("valueChanged",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?l.rules[o].value[a]=r:l.rules[o].value=r;else if(e.className.indexOf("e-radio")>-1)l.rules[o].value=r;else if(e.className.indexOf("e-multiselect")>-1)l.rules[o].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(l.rules[o].type,l.rules[o].value=this.processValueString(r,l.rules[o].type)):l.rules[o].value=r;else if(e.className.indexOf("e-datepicker")>-1){var f=t.getInstance(s.querySelector(".e-rule-filter input"),n.DropDownList),g={type:"dateTime",format:this.columns[f.index].format||"MM/dd/yyyy"};g.type&&(p.indexOf(d)>-1?l.rules[o].value[a]=this.intl.formatDate(r,g):l.rules[o].value=this.intl.formatDate(r,g))}this.validatValue(l,o,s)}},d.prototype.validatValue=function(e,r,n){if(this.allowValidation&&e.rules[r].value){var l=n.querySelectorAll(".e-rule-value .e-control");l[0].className.indexOf("e-tooltip")>-1?t.getComponent(l[0],"tooltip").destroy():l[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[0].parentElement,"tooltip").destroy(),l[1]&&l[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(l[1].parentElement,"tooltip").destroy()}},d.prototype.findGroupByIdx=function(e,t,r){var n=t.rules;if(!r&&n[e]){if((t=n[e]).rules)return t;for(var l=e+1,o=n.length;l<o;l++)if((t=n[l]).rules)return t}return t},d.prototype.destroy=function(){if(this.element){var r,n,l;for(e.prototype.destroy.call(this),l=(r=this.element.querySelectorAll(".e-addrulegroup")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdown-btn").destroy(),t.detach(r[n]);for(l=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdownlist").destroy(),t.detach(r[n]);for(l=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,n=0;n<l;n++)t.getComponent(r[n],"dropdownlist").destroy(),t.detach(r[n]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){for(var r={groupID:t},n=0,l=e.length;n<l;n++)this.addRuleElement(document.getElementById(t),e[n]);this.trigger("ruleInsert",r)},d.prototype.addGroups=function(e,t){var r=document.getElementById(t),n=this.getGroup(r),l={groupID:t};if(e.length)for(var o=0,i=e.length;o<i;o++)this.importRules(e[o],r);else n.rules.push({condition:"and",rules:[]});this.trigger("groupInsert",l)},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),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(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),n=void 0,l=0;l<r.length;l++)n=r.item(l),t.rippleEffect(n,{selector:".e-btn"})}},d.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"}}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),e.appendChild(r),this.element.appendChild(e)},d.prototype.renderSummaryCollapse=function(){var e=this.createElement("button",{attrs:{class:"e-collapse-rule e-css e-btn e-small"}});e.appendChild(this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-collapse-icon"}})),this.element.querySelector(".e-group-header").appendChild(e)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new l.DataManager(this.columns).executeLocal((new l.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new l.DataManager(this.columns).executeLocal((new l.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var n=0,l=Object.keys(e);n<l.length;n++){switch(l[n]){case"summaryView":var o=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content");e.summaryView?(o.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(o.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),o.style.display="block",i.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));break;case"showButtons":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"),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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;break;case"columns":this.columns=e.columns,this.columnSort();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":this.rule=e.rule;break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale}}},d.prototype.preRender=function(){this.defaultLocale={StartsWith:"Starts With",EndsWith:"Ends With",Contains:"Contains",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",Empty:"Empty",NotEmpty:"Not Empty",In:"In",NotIn:"Not In",NotContains:"Not Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization,this.groupIdCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{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")}],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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",empty:"Empty",notempty:"NotEmpty",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],n=t?r.length-1:r.length,l=this.rule,o=0;o<n;o++)l=this.findGroupByIdx(r[o],l,0===o);return l},d.prototype.deleteGroup=function(e){var r,n,l=e,o=l.id,i=this.getGroup(l,!0),s=0,a={groupID:o};this.trigger("groupDelete",a);var u=l.nextElementSibling,p=l.previousElementSibling,d=l.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(n=c.length,r=0;r<n;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,n=d.length;r<n;r++)delete this.levelColl[d[r].id];for(;null!==l.previousElementSibling;)l=l.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),i.rules.splice(s,1),delete this.levelColl[o],t.detach(e)},d.prototype.deleteRule=function(e){var r,n=t.closest(e,".e-group-container"),l=this.getGroup(n),o=t.closest(e,".e-rule-container"),i=o,s=o.nextElementSibling,a=o.previousElementSibling,u={groupID:n.id,ruleID:o.id},p=0,d=o.querySelectorAll(".e-tooltip"),c=d.length;for(r=0;r<c;r++)t.getComponent(d[r],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,p++;l.rules.splice(p,1),this.trigger("ruleDelete",u),(!a||a.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-joined-rule"),(!s||s.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-prev-joined-rule"),t.detach(i)},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteGroup(document.getElementById(e[t]))},d.prototype.getFilteredRecords=function(){var e=(new l.Query).where(this.getPredicate(this.rule));return new l.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteRule(document.getElementById(e[t]))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],n=0,o=Object.keys(this.columns);n<o.length;n++)r.push(this.columns[n].field);return e.rules.length?(new l.Query).select(r).where(t):(new l.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,n,o,i=e.rules,s=!1,a=0,u=i.length;a<u;a++){if(Object.keys(i[a]).indexOf("rules")>-1)(r=this.getPredicate(i[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(i[a].operator.length){var p=i[a].operator.toLowerCase();if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===i[a].type&&["equal","notequal"].indexOf(p)>-1,o=this.getColumn(i[a].field),"date"===i[a].type){var d={type:"dateTime",format:o.format||"MM/dd/yyyy"};n=this.intl.parseDate(i[a].value,d)}else n=i[a].value;if(0===a)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a]);else{""!==(c=n)&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{var c=n;t&&""!==c?t=t.and(i[a].field,i[a].operator,n,s):""!==c&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{c=n;t&&""!==c?t=t.or(i[a].field,i[a].operator,n,s):""!==c&&(t=new l.Predicate(i[a].field,i[a].operator,n,s))}}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,n=0,l=r.length;n<l;n++)r[n].field===e&&(t=r[n]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var n,o=e.value,i=0,s=o.length;i<s;i++)if(""!==o[i])if(0===i)switch(e.operator){case"between":n=new l.Predicate(e.field,"greaterthan",o[i]);break;case"notbetween":n=new l.Predicate(e.field,"lessthan",o[i]);break;case"in":n=new l.Predicate(e.field,"equal",o[i]);break;case"notin":n=new l.Predicate(e.field,"notequal",o[i])}else switch(e.operator){case"between":n=n.and(e.field,"lessthan",o[i]);break;case"notbetween":n=n.or(e.field,"greaterthan",o[i]);break;case"in":n=n.or(e.field,"equal",o[i]);break;case"notin":n=n.and(e.field,"notequal",o[i])}return n&&(t?"and"===r?t=t.and(n):"or"===r&&(t=t.or(n)):t=n),t},d.prototype.importRules=function(e,r,n){n||(r=this.renderGroup(e.condition,r));for(var l=e.rules,o=0,i=l.length;o<i;o++){Object.keys(l[o]).indexOf("rules")>-1?(r=this.renderGroup(l[o].condition,r),r=this.importRules(l[o],r,!0)):this.renderRule(l[o],r)}return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var n=e.condition,l=0,o=e.rules.length;l<o;l++){if(e.rules[l].rules)t=this.getSqlString(e.rules[l],t);else{var i=e.rules[l],s="";if(i.value instanceof Array)if("string"==typeof i.value[0]){s+='("'+i.value[0]+'"';for(var a=1,u=i.value.length;a<u;a++)s+=',"'+i.value[a]+'"';s+=")"}else s+="("+i.value+")";else"startswith"===i.operator?s+='("'+i.value+'%")':"endswith"===i.operator?s+='("%'+i.value+'")':"contains"===i.operator?s+='("%'+i.value+'%")':"number"===i.type?s+=i.value:s+='"'+i.value+'"';t+=i.field+" "+this.operators[i.operator]+" "+s}l!==o-1&&(t+=" "+n+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,n=["=","!=","<",">","<=",">="],l=["and","or"],o=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],i=0,s=n.length;i<s;i++)if(t=/^\w+$/.test(n[i])?"\\b":"",new RegExp("^("+n[i]+")"+t,"ig").exec(e))return this.parser.push(["Operators",n[i].toLowerCase()]),n[i].length;for(i=0,s=l.length;i<s;i++)if(t=/^\w+$/.test(l[i])?"\\b":"",new RegExp("^("+l[i]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",l[i].toLowerCase()]),l[i].length;for(i=0,s=o.length;i<s;i++)if(t=/^\w+$/.test(o[i])?"\\b":"",new RegExp("^("+o[i]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",o[i].toLowerCase()]),o[i].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.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):1},d.prototype.getOperator=function(e,t){return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":{"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"}[t]},d.prototype.processParser=function(e,t,r){for(var n,l,o,i,s,a,u,p,d,c,h=[],m=[],y=0,f=e.length;y<f;y++)if("Literal"===e[y][0]){if(n={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(n.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],o=++y+1,i=f,o=y+1;o<i;o++){if("Right"===e[o][0]){y=o;break}"like"===c&&"String"===e[o][0]?(n.value=e[o][1].replace(/'/g,"").replace(/%/g,""),n.type="string"):"Number"===e[o][0]?h.push(Number(e[o][1])):"String"===e[o][0]&&m.push(e[o][1].replace(/'/g,""))}"like"!==c&&("Number"===e[o-1][0]?(n.value=h,n.type="number"):"String"===e[o-1][0]&&(n.value=m,n.type="string"))}else"Operators"===e[y+1][0]&&(n.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(n.type="number",n.value=Number(e[y+2][1])):(n.type="string",n.value=e[y+2][1].replace(/'/g,"")));t.rules.push(n)}else{if("Left"===e[y][0]){for(l={condition:"",rules:[]},this.parser=e.splice(y+1,f-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(l),l=this.processParser(this.parser,l,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,f-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeConditionChange",void 0),p([t.Event()],d.prototype,"beforeFieldChange",void 0),p([t.Event()],d.prototype,"beforeOperatorChange",void 0),p([t.Event()],d.prototype,"beforeValueChange",void 0),p([t.Event()],d.prototype,"conditionChanged",void 0),p([t.Event()],d.prototype,"fieldChanged",void 0),p([t.Event()],d.prototype,"valueChanged",void 0),p([t.Event()],d.prototype,"operatorChanged",void 0),p([t.Event()],d.prototype,"groupDelete",void 0),p([t.Event()],d.prototype,"ruleDelete",void 0),p([t.Event()],d.prototype,"groupInsert",void 0),p([t.Event()],d.prototype,"ruleInsert",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-buttons"),require("@syncfusion/ej2-dropdowns"),require("@syncfusion/ej2-data"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-calendars"),require("@syncfusion/ej2-splitbuttons"),require("@syncfusion/ej2-popups")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-buttons","@syncfusion/ej2-dropdowns","@syncfusion/ej2-data","@syncfusion/ej2-inputs","@syncfusion/ej2-calendars","@syncfusion/ej2-splitbuttons","@syncfusion/ej2-popups"],t):t(e.ej={},e.ej2Base,e.ej2Buttons,e.ej2Dropdowns,e.ej2Data,e.ej2Inputs,e.ej2Calendars,e.ej2Splitbuttons,e.ej2Popups)}(this,function(e,t,r,l,n,i,o,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function l(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(l.prototype=r.prototype,new l)}}(),p=function(e,t,r,l){var n,i=arguments.length,o=i<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,r):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,l);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(o=(i<3?n(o):i>3?n(t,r,o):n(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o};l.MultiSelect.Inject(l.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(t,r){return e.call(this,t,r)||this}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],r=void 0,l=!1,n=void 0,i={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var o=this.columns,s=0,a=o.length;s<a;s++)o[s].type||(e.indexOf(o[s].field)>-1&&("string"===(r=typeof(n=this.dataColl[0][o[s].field]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),o[s].type=r,l=!1),r="string"),o[s].validation||(o[s].validation=i)}else{for(s=0,a=e.length;s<a;s++)"string"===(r=typeof(n=this.dataColl[0][e[s]]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:l?"date":r,validation:i},l=!1;this.columns=t}}},d.prototype.triggerEvents=function(e,t){return this.isImportRules?e:("before"===t?this.trigger("beforeChange",e):this.trigger("change",e),e)},d.prototype.clickEventHandler=function(e){var r,l=e.target;this.isImportRules=!1;var n;if("SPAN"===l.tagName&&(l=l.parentElement),l.className.indexOf("e-collapse-rule")>-1){var i=new t.Animation({duration:1e3,delay:0}),o=document.getElementById(this.element.id+"_summary_content"),s=o.querySelector(".e-summary-text");i.animate(".e-query-builder",{name:"SlideLeftIn"});(u=this.element.querySelector(".e-group-container")).style.display="none",s.textContent=this.getSqlFromRules(this.rule),o.style.display="block",s.style.height=s.scrollHeight+"px"}if("BUTTON"===l.tagName){if(l.className.indexOf("e-removerule")>-1)l.className.indexOf("e-tooltip")>-1&&t.getComponent(l,"tooltip").destroy(),this.deleteRule(l);else if(l.className.indexOf("e-deletegroup")>-1)t.getComponent(l,"tooltip").destroy(),this.deleteGroup(t.closest(l,".e-group-container"));else if(l.className.indexOf("e-edit-rule")>-1){if((i=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);var a=t.extend({},this.rule,{},!0);this.setGroupRules(a),this.renderSummaryCollapse()}else{var u;(u=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),u.style.display="block"}}}else if("LABEL"===l.tagName&&l.parentElement.className.indexOf("e-btn-group")>-1){var p=t.closest(l,".e-group-container");if(n=p.id.replace(this.element.id+"_",""),r={groupID:n,cancel:!1,type:"condition",value:l.textContent.toLowerCase()},(r=this.triggerEvents(r,"before")).cancel)return;var d=this.getGroup(p);d.condition=r.value,this.triggerEvents({groupID:n,type:"condition",value:d.condition})}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var n={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};if(!(n=this.triggerEvents(n,"before")).cancel){var i=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?i.className="e-rule-container e-vertical-mode":i.className="e-rule-container e-horizontal-mode";var o,s,u,p,d,c,h=e.querySelector(".e-rule-list"),m=i.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)m.textContent=this.l10n.getConstant("Remove"),t.addClass([m],"e-flat"),t.addClass([m],"e-primary");else{t.addClass([m],"e-round"),t.addClass([m],"e-icon-btn");new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(m),m=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),i.querySelector("button").appendChild(m)}if(i.setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.ruleIdCounter++,i.querySelector(".e-filter-input").setAttribute("id",i.id+"_filterkey"),h.appendChild(i),i.previousElementSibling&&i.previousElementSibling.className.indexOf("e-rule-container")>-1&&(i.className.indexOf("e-joined-rule")<0&&(i.className+=" e-joined-rule"),i.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(i.previousElementSibling.className+=" e-prev-joined-rule")),i.previousElementSibling&&i.previousElementSibling.className.indexOf("e-group-container")>-1&&i.className.indexOf("e-separate-rule")<0&&(i.className+=" e-separate-rule"),c=this.element.className.indexOf("e-device")>-1?"250px":"200px",(d=new l.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?c:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+i.id+"_filterkey"),this.filterIndex=d.index,o=this.levelColl[e.id],!this.isImportRules){for(s=this.rule,u=0,p=o.length;u<p;u++)s=this.findGroupByIdx(o[u],s,0===u);Object.keys(r).length?s.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):s.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:d.element,itemData:this.columns[this.filterIndex]}),this.triggerEvents({groupID:e.id.replace(this.element.id+"_",""),type:"insertRule"})}},d.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),position:"BottomCenter",cssClass:"e-querybuilder-error"});t.appendTo(e),t.open(e)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,l=void 0,n=void 0,i=void 0,o=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,l=c.length;r<l;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,i=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,n=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;i&&null!==i.previousElementSibling;)i=i.previousElementSibling,a++;if(n=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),n=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),d.rules[a].value instanceof Array&&(o=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&o.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,f=m.length;y<f;y++){var v=m[y],g=void 0;v.parentElement.className.indexOf("e-searcher")>-1?(g=t.closest(v,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(g):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},d.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)},d.prototype.refreshLevel=function(e){var t,r,l=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,i=l.length,o=0;for(r=0;r<i;r++)(t=l[r]).className.indexOf("e-group-container")>-1&&(e.level.push(o),this.levelColl[t.id]=e.level.slice(),o++,e.groupElement=t,e=this.refreshLevel(e));var s=n.closest(".e-rule-list");return e.groupElement=s?s.closest(".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},d.prototype.groupTemplate=function(){var e,t,r,l,n,i,o,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),l=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(l),e.appendChild(t),n=this.createElement("div",{attrs:{class:"e-btn-group"}}),(i=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),n.appendChild(i),o=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl e-small"},innerHTML:"AND"}),n.appendChild(o),i=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),n.appendChild(i),o=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl e-small"},innerHTML:"OR"}),n.appendChild(o),r.appendChild(n),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,l,n,i;return e=this.createElement("div"),n=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),i=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",l=this.createElement("button",{attrs:{class:i}}),r.appendChild(l),n.appendChild(r),e.appendChild(n),e},d.prototype.addGroupElement=function(e,l,n,i){var o={groupID:l.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};if(!((o=this.triggerEvents(o,"before")).cancel||this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var u,p=this.groupElem.cloneNode(!0);p.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),this.groupIdCounter++;var d=p.querySelector(".e-btngroup-and"),c=p.querySelector(".e-btngroup-or"),h=p.querySelector(".e-btngroup-and-lbl"),m=p.querySelector(".e-btngroup-or-lbl");if(d.setAttribute("id",this.element.id+"_and"+this.btnGroupId),c.setAttribute("id",this.element.id+"_or"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("name",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_and"+this.btnGroupId),m.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var y=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";u=this.createElement("button",{attrs:{class:y}});new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(u);new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(u),t.rippleEffect(u,{selector:".deletegroup"}),p.querySelector(".e-group-action").appendChild(u);for(var f=l.querySelector(".e-rule-list"),v=f.children,g=0,b=0,C=v.length;b<C;b++)v[b].className.indexOf("e-group-container")>-1&&(g+=1);f.appendChild(p);var x=this.levelColl[l.id].slice(0);x.push(g),this.levelColl[p.id]=x,this.isImportRules||(this.addGroups([],l.id.replace(this.element.id+"_","")),i&&this.addRuleElement(p,{}))}else l.appendChild(p),this.levelColl[p.id]=[0];p.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===n&&p.querySelector(".e-btngroup-or").setAttribute("checked","true");var E=p.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,E),select:this.selectBtn.bind(this,E)}).appendTo(E),t.rippleEffect(E,{selector:".e-round"}),this.triggerEvents({groupID:l.id.replace(this.element.id+"_",""),type:"insertGroup"})}},d.prototype.notifyChange=function(e,r){for(var l=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),n=[],i=0,o=l.length;i<o;i++)l[i].nextElementSibling&&l[i].nextElementSibling.className.indexOf("e-check")>-1&&n.push(l[i].textContent);this.updateRules(r,l.length>1?n:e)},d.prototype.changeValue=function(e,r){var l,n,i,o;if(r.event)o=r.event.target;else{o=r.element}if(o.className.indexOf("e-day")>-1){o=r.element}var s=t.closest(o,".e-group-container"),a=t.closest(o,".e-rule-container");n=s.id.replace(this.element.id+"_",""),i=a.id.replace(this.element.id+"_","");var u=r;u.element&&u.element.className.indexOf("e-datepicker")>-1&&(o=u.element);l={groupID:n,ruleID:i,value:o.className.indexOf("e-radio")>-1?t.getComponent(o,"radio").label:o.className.indexOf("e-multiselect")>-1?t.getComponent(o,"multiselect").value:r.value,cancel:!1,type:"value"},(l=this.triggerEvents(l,"before")).cancel||(this.updateRules(o,l.value,e),this.triggerEvents({groupID:n,ruleID:i,value:l.value,cancel:!1,type:"value"}))},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),l=this.getGroup(r),n=t.closest(e.element,".e-rule-container"),i=0;n&&null!==n.previousElementSibling;)n=n.previousElementSibling,i++;this.changeRule(l.rules[i],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var n,i,o,s,a,u,p,d,c={},h=e.operator?e.operator.toLowerCase():"";u=t.closest(r.element,".e-rule-filter"),p=t.closest(r.element,".e-rule-operator");var m=t.getComponent(r.element,"dropdownlist");s=t.closest(r.element,".e-group-container").id.replace(this.element.id+"_","");var y;if(u){if(i=t.closest(u,".e-rule-container"),a=i.id.replace(this.element.id+"_",""),y={groupID:s,ruleID:a,selectedIndex:m.index,cancel:!1,type:"field"},(y=this.triggerEvents(y,"before")).cancel)return;m.index!==y.selectedIndex&&(m.index=y.selectedIndex),c.type=this.columns[m.index].type,i.querySelector(".e-template")&&(e.value="")}if(p){if(i=t.closest(p,".e-rule-container"),a=i.id.replace(this.element.id+"_",""),y={groupID:s,ruleID:a,selectedIndex:m.index,cancel:!1,type:"operator"},(y=this.triggerEvents(y,"before")).cancel)return;m.index!==y.selectedIndex&&(m.index=y.selectedIndex),c.operator=m.value;var f=c.operator.toLowerCase();if(c.operator.toLowerCase().indexOf("between")>-1||c.operator.toLowerCase().indexOf("in")>-1&&c.operator.toLowerCase().indexOf("contains")<0?(u=p.previousElementSibling,c.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var v=r.previousItemData.value.toLowerCase();(v.indexOf("between")>-1||v.indexOf("in")>-1&&v.indexOf("contains")<0)&&(u=p.previousElementSibling,c.type=e.type)}h.indexOf("in")>-1&&h.indexOf("in")<5&&f.indexOf("in")>-1&&f.indexOf("in")<5&&(u=null)}if(u)if(p=u.nextElementSibling,t.addClass([p],"e-operator"),p.childElementCount)n=t.getComponent(p.querySelector(".e-dropdownlist"),"dropdownlist"),c.operator=n.value,this.renderValues(p,r.itemData,r.previousItemData,!0,e,c,r.element);else{var g=t.closest(p,".e-rule-container").id;d=this.createElement("input",{attrs:{type:"text",id:g+"_operatorkey"}}),p.appendChild(d),this.columns[m.index].operators?o=this.columns[m.index].operators:r.itemData&&(o=this.customOperators[this.columns[m.index].type+"Operator"]);var b=this.element.className.indexOf("e-device")>-1?"250px":"200px";new l.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?b:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+g+"_operatorkey"),c.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(c.type=this.columns[m.index].type,c.operator=e.operator),this.renderValues(p,this.columns[m.index],r.previousItemData,!1,e,c,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var l;l=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var n=this.columns,i=0,o=r.length;i<o;i++){if(r[i].classList.contains("e-textbox"))t.getComponent(r[i],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[i].id));else if(r[i].classList.contains("e-dropdownlist"))t.getComponent(r[i],"dropdownlist").destroy();else if(r[i].classList.contains("e-radio"))t.getComponent(r[i],"radio").destroy();else if(r[i].classList.contains("e-numerictextbox"))t.getComponent(r[i],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[i].id));else if(r[i].classList.contains("e-datepicker"))t.getComponent(r[i],"datepicker").destroy();else if(r[i].classList.contains("e-multiselect"))t.getComponent(r[i],"multiselect").destroy();else if(r[i].className.indexOf("e-template")>-1)for(var s=r[i].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],r[i].id);break}document.getElementById(r[i].id)&&t.detach(r[i])}for(i=0,o=l.length;i<o;i++){if(l[i].className.indexOf("e-template")>-1)for(s=l[i].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],l[i].id);break}t.detach(l[i])}},d.prototype.templateDestroy=function(e,r){var l=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof l?(l=t.getValue(l,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},l=[],n=0,i=e.length;n<i;n++){var o=e[n][t];Number(e[n][t])===e[n][t]&&e[n][t]%1!=0&&(o=e[n][t].toString());var s={};o in r||(r[o]=1,s[t]=o,l.push(s))}return l},d.prototype.renderMultiSelect=function(e,t,r,i){var o=this.getDistinctValues(this.dataColl,e.field);new l.MultiSelect({dataSource:new n.DataManager(o),query:new n.Query([e.field]),fields:{text:e.field,value:e.field},value:i,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r),close:this.closePopup.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.closePopup=function(e,r){var l=document.getElementById(r.popup.element.id.replace("_popup","")),n=t.getComponent(l,"multiselect").value;this.updateRules(l,n,e)},d.prototype.processTemplate=function(e,r,l,n){var i=t.closest(e,".e-rule-container").querySelectorAll(".e-template");i.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:i[0],values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:i[0],values:l.value,operator:n.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:i,values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:i,values:l.value,operator:n.operator})},d.prototype.renderStringValue=function(e,t,r,l,n){var o,s=this.isImportRules?t.value:"";if("in"!==r&&"notin"!==r||!this.dataColl.length){"in"!==r&&"notin"!==r||(s=(o=this.isImportRules?t.value:[]).join(","));var a=new i.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});a.appendTo("#"+e+"_valuekey"+l),a.value=s,a.dataBind()}else o=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,l,o),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.style.width="100%":(n.style.width=null,n.style.minWidth="200px")},d.prototype.renderNumberValue=function(e,r,l,n,o,s,a){var u,p=this.isImportRules?r.value:0;if("in"!==l&&"notin"!==l||!this.dataColl.length)if("in"===l||"notin"===l){var d=(u=this.isImportRules?r.value:[]).join(","),c=new i.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});c.appendTo("#"+e+"_valuekey"+n),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,f=s.format?s.format:"n";a>1&&r&&(p=r.value[n]?r.value[n]:0);new i.NumericTextBox({value:p,format:f,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,n)}).appendTo("#"+e+"_valuekey"+n)}else u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,n,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?o.style.width="100%":(o.style.minWidth="200px",o.style.width=null)},d.prototype.processValueString=function(e,t){var r=[],l=e.split(",");if("string"===t)return l;for(var n=0,i=l.length;n<i;n++)r.push(Number(l[n]));return r},d.prototype.renderControls=function(e,l,n,i){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),l.template)this.processTemplate(e,l,n,i);else{var s="boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;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"!==i.operator&&"notin"!==i.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(i.type){case"string":this.renderStringValue(a,n,i.operator,p,u);break;case"number":this.renderNumberValue(a,n,i.operator,p,u,l,s);break;case"boolean":var d=l.values&&l.values.length?l.values:["True","False"],c=!this.isImportRules||Boolean(n.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&n&&n.value){h=s>1?new Date(n.value[p]):new Date(n.value);var y=void 0,f=this.getColumn(n.field);if(m=s>1?n.value[p]:n.value,f.format){var v=this.intl.getDateParser({skeleton:"full",type:"dateTime"});y={type:"dateTime",format:f.format},"Invalid Date"===h.toLocaleDateString()&&(h=v(m),t.isNullOrUndefined(h)&&(h=this.intl.parseDate(m,y)))}}(l.format?new o.DatePicker({value:h,format:l.format,change:this.changeValue.bind(this,p)}):new o.DatePicker({value:h,change:this.changeValue.bind(this,p)})).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,l,n,i,o,s){if(n){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),o.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),o.operator=a.value)}var u=t.closest(e,".e-rule-container").id;l&&l.template&&(this.templateDestroy(l,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),n&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;var c=void 0;if(r.template&&"string"==typeof r.template.create?c=t.getValue(r.template.create,window)():r.template&&r.template.create&&(c=r.template.create()),c instanceof Element)c.id=u+"_valuekey0",t.addClass([c],"e-template"),t.addClass([c],"e-"+r.field),e.nextElementSibling.appendChild(c);else if(c instanceof Array){t.addClass(c,"e-template");for(var h=0,m=c.length;h<m;h++)c[h].id=u+"_valuekey"+h,e.nextElementSibling.appendChild(c[h])}var y=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?y.style.width="100%":y.style.minWidth="200px"}else if("boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1)for(h=0;h<2;h++){c=void 0;c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+h}}),e.nextElementSibling.appendChild(c)}else{c=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(c)}this.renderControls(e,r,i,o)},d.prototype.updateValues=function(e,r){var l=e.className.split(" e-")[1],n=parseInt(e.id.slice(-1),2);switch(l){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,l).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=t.getComponent(e,l).value;break;case"datepicker":var i={type:"dateTime",format:this.getColumn(r.field).format};r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:t.isNullOrUndefined(i.format)?r.value=this.intl.formatDate(t.getComponent(e,l).value):r.value=this.intl.formatDate(t.getComponent(e,l).value,i)}},d.prototype.updateRules=function(e,r,l){for(var n,i,o,s=t.closest(e,".e-group-container"),a=this.getGroup(s),u=t.closest(e,".e-rule-container"),p=0,d=s.id.replace(this.element.id+"_","");u&&null!==u.previousElementSibling;)u=u.previousElementSibling,p++;if(u=t.closest(e,".e-rule-container"),o=u.id.replace(this.element.id+"_",""),t.closest(e,".e-rule-filter")){n=t.getComponent(e,"dropdownlist"),a.rules[p].field=this.columns[n.index].field,a.rules[p].type=this.columns[n.index].type,a.rules[p].label=this.columns[n.index].label;var c=t.closest(e,".e-rule-filter"),h=c.nextElementSibling.querySelector("input.e-control"),m=t.getComponent(h,"dropdownlist").value;a.rules[p].operator=m,(h=c.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(h=c.nextElementSibling.nextElementSibling.querySelector("div.e-control")),i={groupID:d,ruleID:o,value:a.rules[p].field,type:"field"},this.updateValues(h,a.rules[p]),this.triggerEvents(i),this.allowValidation&&a.rules[p].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),a.rules[p].operator=n.value;var y=void 0;e.parentElement;y=u.querySelectorAll(".e-rule-value input.e-control"),i={groupID:d,ruleID:o,value:n.value,type:"operator"},this.allowValidation&&a.rules[p].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),y.length>1&&(a.rules[p].value=[]);for(var f=0;f<y.length;f++)this.updateValues(y[f],a.rules[p]);this.triggerEvents(i)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,a,p,s,u,l)},d.prototype.ruleValueUpdate=function(e,r,n,i,o,s,a){var u,p=["in","between","notin","notbetween"];if(null!==r){var d=n.rules[i].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===n.rules[i].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?n.rules[i].value=r:n.rules[i].value=r[0]:n.rules[i].value=r,u={groupID:o.id,ruleID:s.id,value:n.rules[i].value,type:"value"},this.triggerEvents(u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?n.rules[i].value[a]=r:n.rules[i].value=r;else if(e.className.indexOf("e-radio")>-1)n.rules[i].value=r;else if(e.className.indexOf("e-multiselect")>-1)n.rules[i].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(n.rules[i].type,n.rules[i].value=this.processValueString(r,n.rules[i].type)):n.rules[i].value=r;else if(e.className.indexOf("e-datepicker")>-1){var f=t.getInstance(s.querySelector(".e-rule-filter input"),l.DropDownList),v={type:"dateTime",format:this.columns[f.index].format||"MM/dd/yyyy"};v.type&&(p.indexOf(d)>-1?n.rules[i].value[a]=this.intl.formatDate(r,v):n.rules[i].value=this.intl.formatDate(r,v))}this.validatValue(n,i,s)}},d.prototype.validatValue=function(e,r,l){if(this.allowValidation&&e.rules[r].value){var n=l.querySelectorAll(".e-rule-value .e-control");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()}},d.prototype.findGroupByIdx=function(e,t,r){var l=t.rules,n=[];if(!r){for(var i=0,o=l.length;i<o;i++)(t=l[i]).rules&&n.push(t);return n[e]}return t},d.prototype.destroy=function(){if(this.element){var r,l,n;for(e.prototype.destroy.call(this),n=(r=this.element.querySelectorAll(".e-addrulegroup")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdown-btn").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){t=this.element.id+"_"+t;for(var r=0,l=e.length;r<l;r++)this.addRuleElement(document.getElementById(t),e[r])},d.prototype.addGroups=function(e,t){t=this.element.id+"_"+t;var r=document.getElementById(t),l=this.getGroup(r);if(e.length)for(var n=0,i=e.length;n<i;n++)this.importRules(e[n],r);else l.rules.push({condition:"and",rules:[]})},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),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(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),l=void 0,n=0;n<r.length;n++)l=r.item(n),t.rippleEffect(l,{selector:".e-btn"})}},d.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"}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),l=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),l.appendChild(r),e.appendChild(l),this.element.appendChild(e)},d.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)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var l=0,n=Object.keys(e);l<n.length;l++){switch(n[l]){case"summaryView":var i=this.element.querySelector(".e-group-container"),o=this.element.querySelector(".e-summary-content");e.summaryView?(i.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),o=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),o.style.display="block"):(i.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),i.style.display="block",o.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));break;case"showButtons":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"),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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;break;case"columns":this.columns=e.columns,this.columnSort();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":this.rule=e.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)}}},d.prototype.preRender=function(){this.defaultLocale={StartsWith:"Starts With",EndsWith:"Ends With",Contains:"Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization(this.locale),this.groupIdCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{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")}],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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.dataSource instanceof n.DataManager?(this.dataManager=this.dataSource,this.executeDataManager(new n.Query)):(this.dataManager=new n.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new n.Query),this.initControl())},d.prototype.executeDataManager=function(e){var t=this,r=this.dataManager.executeQuery(e),l=new n.Deferred;r.then(function(e){t.dataColl=e.result,t.initControl()}).catch(function(e){l.reject(e)})},d.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],l=t?r.length-1:r.length,n=this.rule,i=0;i<l;i++)n=this.findGroupByIdx(r[i],n,0===i);return n},d.prototype.deleteGroup=function(e){var r,l,n=e,i=n.id.replace(this.element.id+"_",""),o=this.getGroup(n,!0),s=0,a={groupID:i,cancel:!1,type:"deleteGroup"};if(!(a=this.triggerEvents(a,"before")).cancel){var u=n.nextElementSibling,p=n.previousElementSibling,d=n.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(l=c.length,r=0;r<l;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,l=d.length;r<l;r++)delete this.levelColl[d[r].id];for(;null!==n.previousElementSibling;)n=n.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),o.rules.splice(s,1),delete this.levelColl[i],t.detach(e),this.refreshLevelColl(),this.triggerEvents(a)}},d.prototype.deleteRule=function(e){var r=t.closest(e,".e-group-container"),l=this.getGroup(r),n=t.closest(e,".e-rule-container"),i={groupID:r.id.replace(this.element.id+"_",""),ruleID:e.closest(".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};if(!(i=this.triggerEvents(i,"before")).cancel){var o,s=n,a=n.nextElementSibling,u=n.previousElementSibling,p=0,d=n.querySelectorAll(".e-tooltip"),c=d.length;for(o=0;o<c;o++)t.getComponent(d[o],"tooltip").destroy();for(;null!==n.previousElementSibling;)n=n.previousElementSibling,p++;l.rules.splice(p,1),(!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"),t.detach(s),this.triggerEvents(i)}},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r,l=e.length;for(t=0;t<l;t++)r=this.element.id+"_"+e[t],this.deleteGroup(document.getElementById(r))},d.prototype.getFilteredRecords=function(){var e=(new n.Query).where(this.getPredicate(this.rule));return new n.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r,l=e.length;for(t=0;t<l;t++)r=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(r))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],l=0,i=Object.keys(this.columns);l<i.length;l++)r.push(this.columns[l].field);return e.rules.length?(new n.Query).select(r).where(t):(new n.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,l,i,o=e.rules,s=!1,a=0,u=o.length;a<u;a++){if(Object.keys(o[a]).indexOf("rules")>-1)(r=this.getPredicate(o[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(o[a].operator.length){var p=o[a].operator.toLowerCase();if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===o[a].type&&["equal","notequal"].indexOf(p)>-1,i=this.getColumn(o[a].field),"date"===o[a].type){var d={type:"dateTime",format:i.format||"MM/dd/yyyy"};l=this.intl.parseDate(o[a].value,d)}else l=o[a].value;if(0===a)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(o[a]);else{""!==(c=l)&&(t=new n.Predicate(o[a].field,o[a].operator,l,s))}else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(o[a],t,e.condition);else{var c=l;t&&""!==c?t=t.and(o[a].field,o[a].operator,l,s):""!==c&&(t=new n.Predicate(o[a].field,o[a].operator,l,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(o[a],t,e.condition);else{c=l;t&&""!==c?t=t.or(o[a].field,o[a].operator,l,s):""!==c&&(t=new n.Predicate(o[a].field,o[a].operator,l,s))}}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,l=0,n=r.length;l<n;l++)r[l].field===e&&(t=r[l]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var l,i=e.value,o=0,s=i.length;o<s;o++)if(""!==i[o])if(0===o)switch(e.operator){case"between":l=new n.Predicate(e.field,"greaterthan",i[o]);break;case"notbetween":l=new n.Predicate(e.field,"lessthan",i[o]);break;case"in":l=new n.Predicate(e.field,"equal",i[o]);break;case"notin":l=new n.Predicate(e.field,"notequal",i[o])}else switch(e.operator){case"between":l=l.and(e.field,"lessthan",i[o]);break;case"notbetween":l=l.or(e.field,"greaterthan",i[o]);break;case"in":l=l.or(e.field,"equal",i[o]);break;case"notin":l=l.and(e.field,"notequal",i[o])}return l&&(t?"and"===r?t=t.and(l):"or"===r&&(t=t.or(l)):t=l),t},d.prototype.importRules=function(e,r,l){l||(r=this.renderGroup(e.condition,r));var n=e.rules;if(!t.isNullOrUndefined(n))for(var i=0,o=n.length;i<o;i++){var s=Object.keys(n[i]);!t.isNullOrUndefined(n[i].rules)&&s.indexOf("rules")>-1?(r=this.renderGroup(n[i].condition,r),r=this.importRules(n[i],r,!0)):this.renderRule(n[i],r)}return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var l=e.condition,n=0,i=e.rules.length;n<i;n++){if(e.rules[n].rules)t=this.getSqlString(e.rules[n],t);else{var o=e.rules[n],s="";if(o.value instanceof Array)if(o.operator.indexOf("between")>-1)s+=o.value[0]+" AND "+o.value[1];else if("string"==typeof o.value[0]){s+='("'+o.value[0]+'"';for(var a=1,u=o.value.length;a<u;a++)s+=',"'+o.value[a]+'"';s+=")"}else s+="("+o.value+")";else"startswith"===o.operator?s+='("'+o.value+'%")':"endswith"===o.operator?s+='("%'+o.value+'")':"contains"===o.operator?s+='("%'+o.value+'%")':"number"===o.type?s+=o.value:s+='"'+o.value+'"';t+=o.field+" "+this.operators[o.operator]+" "+s}n!==i-1&&(t+=" "+l+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,l=["=","!=","<",">","<=",">="],n=["and","or"],i=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],o=0,s=l.length;o<s;o++)if(t=/^\w+$/.test(l[o])?"\\b":"",new RegExp("^("+l[o]+")"+t,"ig").exec(e))return this.parser.push(["Operators",l[o].toLowerCase()]),l[o].length;for(o=0,s=n.length;o<s;o++)if(t=/^\w+$/.test(n[o])?"\\b":"",new RegExp("^("+n[o]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",n[o].toLowerCase()]),n[o].length;for(o=0,s=i.length;o<s;o++)if(t=/^\w+$/.test(i[o])?"\\b":"",new RegExp("^("+i[o]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",i[o].toLowerCase()]),i[o].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.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):1},d.prototype.getOperator=function(e,t){return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":{"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"}[t]},d.prototype.processParser=function(e,t,r){for(var l,n,i,o,s,a,u,p,d,c,h=[],m=[],y=0,f=e.length;y<f;y++)if("Literal"===e[y][0]){if(l={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(l.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],i=++y+1,o=f,i=y+1;i<o;i++){if("Right"===e[i][0]){y=i;break}if("like"===c&&"String"===e[i][0])l.value=e[i][1].replace(/'/g,"").replace(/%/g,""),l.type="string";else if("between"===c){if("Literal"===e[i][0]||"Left"===e[i][0])break;"Number"===e[i][0]&&h.push(Number(e[i][1]))}else"Number"===e[i][0]?h.push(Number(e[i][1])):"String"===e[i][0]&&m.push(e[i][1].replace(/'/g,""))}"like"!==c&&("Number"===e[i-1][0]?(l.value=h,l.type="number"):"String"===e[i-1][0]?(l.value=m,l.type="string"):"between"===c&&"Conditions"===e[i-1][0]&&(l.value=h,l.type="number"))}else"Operators"===e[y+1][0]&&(l.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(l.type="number",l.value=Number(e[y+2][1])):(l.type="string",l.value=e[y+2][1].replace(/'/g,"")));t.rules.push(l)}else{if("Left"===e[y][0]){for(n={condition:"",rules:[]},this.parser=e.splice(y+1,f-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(n),n=this.processParser(this.parser,n,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,f-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeChange",void 0),p([t.Event()],d.prototype,"change",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ej2-querybuilder.umd.min.js.map
/*!
* filename: ej2-querybuilder.min.js
* version : 17.1.1-beta
* version : 17.1.32-beta
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.

@@ -10,3 +10,3 @@ * Use of this code is subject to the terms of our license.

*/
this.ej=this.ej||{},this.ej.querybuilder=function(e,t,r,l,n,o,i,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function l(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(l.prototype=r.prototype,new l)}}(),p=function(e,t,r,l){var n,o=arguments.length,i=o<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,r):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,l);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i};l.MultiSelect.Inject(l.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(t,r){return e.call(this,t,r)||this}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataSource.length){var e=Object.keys(this.dataSource[0]),t=[],r=void 0,l=!1,n=void 0,o={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var i=this.columns,s=0,a=i.length;s<a;s++)i[s].type||(e.indexOf(i[s].field)>-1&&("string"===(r=typeof(n=this.dataSource[0][i[s].field]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),i[s].type=r,l=!1),r="string"),i[s].validation||(i[s].validation=o)}else{for(var s=0,a=e.length;s<a;s++)"string"===(r=typeof(n=this.dataSource[0][e[s]]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:l?"date":r,validation:o},l=!1;this.columns=t}}},d.prototype.clickEventHandler=function(e){var r=e.target;if(this.isImportRules=!1,"SPAN"===r.tagName&&(r=r.parentElement),"BUTTON"===r.tagName){if(r.className.indexOf("e-removerule")>-1)r.className.indexOf("e-tooltip")>-1&&t.getComponent(r,"tooltip").destroy(),this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)t.getComponent(r,"tooltip").destroy(),this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if(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);var l=t.extend({},this.rule,{},!0);this.setGroupRules(l),this.renderSummaryCollapse()}else(n=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),n.style.display="block";else if(r.className.indexOf("e-collapse-rule")>-1){var n=this.element.querySelector(".e-group-container");n.style.display="none",this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),document.getElementById(this.element.id+"_summary_content").style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1){var o=t.closest(r,".e-group-container"),i={groupID:o.id,selectedItem:r,cancel:!1};this.trigger("beforeConditionChange",i),this.getGroup(o).condition=r.textContent.toLowerCase(),i={groupID:o.id,selectedItem:r},this.trigger("conditionChanged",i)}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var n=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.className="e-rule-container e-vertical-mode":n.className="e-rule-container e-horizontal-mode";var o,i,s,u,p,d,c=e.querySelector(".e-rule-list"),h=n.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?h.textContent=this.l10n.getConstant("Remove"):(t.addClass([h],"e-round"),t.addClass([h],"e-icon-btn"),new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(h),h=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),n.querySelector("button").appendChild(h)),n.setAttribute("id",e.id+"_e_rule"+this.ruleIdCounter),this.ruleIdCounter++,n.querySelector(".e-filter-input").setAttribute("id",n.id+"_filterkey"),c.appendChild(n),n.previousElementSibling&&n.previousElementSibling.className.indexOf("e-rule-container")>-1&&(n.className.indexOf("e-joined-rule")<0&&(n.className+=" e-joined-rule"),n.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(n.previousElementSibling.className+=" e-prev-joined-rule")),n.previousElementSibling&&n.previousElementSibling.className.indexOf("e-group-container")>-1&&n.className.indexOf("e-separate-rule")<0&&(n.className+=" e-separate-rule"),d=this.element.className.indexOf("e-device")>-1?"250px":"200px",(p=new l.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?d:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+n.id+"_filterkey"),this.filterIndex=p.index,o=this.levelColl[e.id],!this.isImportRules){for(i=this.rule,s=0,u=o.length;s<u;s++)i=this.findGroupByIdx(o[s],i,0===s);Object.keys(r).length?i.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):i.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:p.element,itemData:this.columns[this.filterIndex]})},d.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),position:"BottomCenter",cssClass:"e-querybuilder-error"});t.appendTo(e),t.open(e)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,l=void 0,n=void 0,o=void 0,i=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,l=c.length;r<l;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,o=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,n=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,a++;if(n=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),n=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),d.rules[a].value instanceof Array&&(i=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&i.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,g=m.length;y<g;y++){var v=m[y],f=void 0;v.parentElement.className.indexOf("e-searcher")>-1?(f=t.closest(v,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(f):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},d.prototype.groupTemplate=function(){var e,t,r,l,n,o,i,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),l=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(l),e.appendChild(t),n=this.createElement("div",{attrs:{class:"e-btn-group"}}),(o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),n.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl"},innerHTML:"AND"}),n.appendChild(i),o=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),n.appendChild(o),i=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl"},innerHTML:"OR"}),n.appendChild(i),r.appendChild(n),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,l,n,o;return e=this.createElement("div"),n=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),o=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",l=this.createElement("button",{attrs:{class:o}}),r.appendChild(l),n.appendChild(r),e.appendChild(n),e},d.prototype.addGroupElement=function(e,l,n,o){if(!(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var i,u=this.groupElem.cloneNode(!0);u.setAttribute("id",this.element.id+"_e_group"+this.groupIdCounter),this.groupIdCounter++;var p=u.querySelector(".e-btngroup-and"),d=u.querySelector(".e-btngroup-or"),c=u.querySelector(".e-btngroup-and-lbl"),h=u.querySelector(".e-btngroup-or-lbl");if(p.setAttribute("id",this.element.id+"_and"+this.btnGroupId),d.setAttribute("id",this.element.id+"_or"+this.btnGroupId),p.setAttribute("name",this.element.id+"_and"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var m=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";i=this.createElement("button",{attrs:{class:m}}),new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(i),new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(i),t.rippleEffect(i,{selector:".deletegroup"}),u.querySelector(".e-group-action").appendChild(i);var y=l.querySelector(".e-rule-list"),g=l.querySelectorAll(".e-group-container").length;y.appendChild(u);var v=this.levelColl[l.id].slice(0);v.push(g),this.levelColl[u.id]=v,this.isImportRules||(this.addGroups([],l.id),o&&this.addRuleElement(u,{}))}else l.appendChild(u),this.levelColl[u.id]=[0];u.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===n&&u.querySelector(".e-btngroup-or").setAttribute("checked","true");var f=u.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,f),select:this.selectBtn.bind(this,f)}).appendTo(f),t.rippleEffect(f,{selector:".e-round"})}},d.prototype.notifyChange=function(e,r){for(var l=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),n=[],o=0,i=l.length;o<i;o++)l[o].nextElementSibling&&l[o].nextElementSibling.className.indexOf("e-check")>-1&&n.push(l[o].textContent);this.updateRules(r,l.length>1?n:e)},d.prototype.changeValue=function(e,r){var l,n;(n=r.event?r.event.target:r.element).className.indexOf("e-day")>-1&&(n=r.element);var o=t.closest(n,".e-group-container"),i=t.closest(n,".e-rule-container"),s=r;s.element&&s.element.className.indexOf("e-datepicker")>-1&&(n=s.element);var a;a=n.className.indexOf("e-radio")>-1?t.getComponent(n,"radio").label:n.className.indexOf("e-multiselect")>-1?t.getComponent(n,"multiselect").value:r.value,l={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("beforeValueChange",l),this.updateRules(n,a,e),l={groupID:o.id,ruleID:i.id,value:a,cancel:!1},this.trigger("valueChanged",l)},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),l=this.getGroup(r),n=t.closest(e.element,".e-rule-container"),o=0;n&&null!==n.previousElementSibling;)n=n.previousElementSibling,o++;this.changeRule(l.rules[o],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var n,o,i,s,a,u={},p=e.operator?e.operator.toLowerCase():"";i=t.closest(r.element,".e-rule-filter"),s=t.closest(r.element,".e-rule-operator");var d=t.getComponent(r.element,"dropdownlist"),c=t.closest(r.element,".e-group-container");if(i){var h=t.closest(i,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeFieldChange",m),u.type=this.columns[d.index].type,h.querySelector(".e-template")&&(e.value="")}if(s){var h=t.closest(s,".e-rule-container"),m={groupID:c.id,ruleID:h.id,selectedItem:r.item,cancel:!1};this.trigger("beforeOperatorChange",m),u.operator=r.itemData.value;var y=u.operator.toLowerCase();if(u.operator.toLowerCase().indexOf("between")>-1||u.operator.toLowerCase().indexOf("in")>-1&&u.operator.toLowerCase().indexOf("contains")<0?(i=s.previousElementSibling,u.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var g=r.previousItemData.value.toLowerCase();(g.indexOf("between")>-1||g.indexOf("in")>-1&&g.indexOf("contains")<0)&&(i=s.previousElementSibling,u.type=e.type)}p.indexOf("in")>-1&&p.indexOf("in")<5&&y.indexOf("in")>-1&&y.indexOf("in")<5&&(i=null)}if(i)if(s=i.nextElementSibling,t.addClass([s],"e-operator"),s.childElementCount)n=t.getComponent(s.querySelector(".e-dropdownlist"),"dropdownlist"),u.operator=n.value,this.renderValues(s,r.itemData,r.previousItemData,!0,e,u,r.element);else{var v=t.closest(s,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:v+"_operatorkey"}}),s.appendChild(a),this.columns[d.index].operators?o=this.columns[d.index].operators:r.itemData&&(o=this.customOperators[this.columns[d.index].type+"Operator"]);var f=this.element.className.indexOf("e-device")>-1?"250px":"200px";new l.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?f:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+v+"_operatorkey"),u.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(u.type=this.columns[d.index].type,u.operator=e.operator),this.renderValues(s,this.columns[d.index],r.previousItemData,!1,e,u,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var l;l=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var n=this.columns,o=0,i=r.length;o<i;o++){if(r[o].classList.contains("e-textbox"))t.getComponent(r[o],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-dropdownlist"))t.getComponent(r[o],"dropdownlist").destroy();else if(r[o].classList.contains("e-radio"))t.getComponent(r[o],"radio").destroy();else if(r[o].classList.contains("e-numerictextbox"))t.getComponent(r[o],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[o].id));else if(r[o].classList.contains("e-datepicker"))t.getComponent(r[o],"datepicker").destroy();else if(r[o].classList.contains("e-multiselect"))t.getComponent(r[o],"multiselect").destroy();else if(r[o].className.indexOf("e-template")>-1)for(var s=r[o].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],r[o].id);break}document.getElementById(r[o].id)&&t.detach(r[o])}for(var o=0,i=l.length;o<i;o++){if(l[o].className.indexOf("e-template")>-1)for(var s=l[o].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],l[o].id);break}t.detach(l[o])}},d.prototype.templateDestroy=function(e,r){var l=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof l?(l=t.getValue(l,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},l=[],n=0,o=e.length;n<o;n++){var i=e[n][t];Number(e[n][t])===e[n][t]&&e[n][t]%1!=0&&(i=e[n][t].toString());var s={};i in r||(r[i]=1,s[t]=i,l.push(s))}return l},d.prototype.renderMultiSelect=function(e,t,r,o){var i=this.getDistinctValues(this.dataSource,e.field);new l.MultiSelect({dataSource:new n.DataManager(i),query:new n.Query([e.field]),fields:{text:e.field,value:e.field},value:o,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.processTemplate=function(e,r,l,n){var o=t.closest(e,".e-rule-container").querySelectorAll(".e-template");o.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o[0],values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:o[0],values:l.value,operator:n.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:o,values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:o,values:l.value,operator:n.operator})},d.prototype.renderStringValue=function(e,t,r,l,n){var i,s=this.isImportRules?t.value:"";if(("in"===r||"notin"===r)&&this.dataSource.length>0)i=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,l,i),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.style.width="100%":(n.style.width=null,n.style.minWidth="200px");else{"in"!==r&&"notin"!==r||(s=(i=this.isImportRules?t.value:[]).join(","));var a=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});a.appendTo("#"+e+"_valuekey"+l),a.value=s,a.dataBind()}},d.prototype.renderNumberValue=function(e,r,l,n,i,s,a){var u,p=this.isImportRules?r.value:0;if(("in"===l||"notin"===l)&&this.dataSource.length>0)u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,n,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null);else if("in"===l||"notin"===l){var d=(u=this.isImportRules?r.value:[]).join(","),c=new o.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});c.appendTo("#"+e+"_valuekey"+n),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,g=s.format?s.format:"#";a>1&&r&&(p=r.value[n]?r.value[n]:0),new o.NumericTextBox({value:p,format:g,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,n)}).appendTo("#"+e+"_valuekey"+n)}},d.prototype.processValueString=function(e,t){var r=[],l=e.split(",");if("string"===t)return l;for(var n=0,o=l.length;n<o;n++)r.push(Number(l[n]));return r},d.prototype.renderControls=function(e,l,n,o){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),l.template)this.processTemplate(e,l,n,o);else{var s="boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;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"!==o.operator&&"notin"!==o.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(o.type){case"string":this.renderStringValue(a,n,o.operator,p,u);break;case"number":this.renderNumberValue(a,n,o.operator,p,u,l,s);break;case"boolean":var d=l.values&&l.values.length?l.values:["True","False"],c=!this.isImportRules||Boolean(n.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&n&&n.value){h=s>1?new Date(n.value[p]):new Date(n.value);var y=void 0,g=this.getColumn(n.field);m=s>1?n.value[p]:n.value,y={type:"dateTime",format:g.format||"MM/dd/yyyy"},h=this.intl.parseDate(m,y)}var v=l.format?l.format:"MM/dd/yyyy";new i.DatePicker({value:h,format:v,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,l,n,o,i,s){if(n){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),i.operator=a.value)}var u=t.closest(e,".e-rule-container").id;l&&l.template&&(this.templateDestroy(l,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),n&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;y=void 0;if(r.template&&"string"==typeof r.template.create?y=t.getValue(r.template.create,window)():r.template&&r.template.create&&(y=r.template.create()),y instanceof Element)y.id=u+"_valuekey0",t.addClass([y],"e-template"),t.addClass([y],"e-"+r.field),e.nextElementSibling.appendChild(y);else if(y instanceof Array){t.addClass(y,"e-template");for(var c=0,h=y.length;c<h;c++)y[c].id=u+"_valuekey"+c,e.nextElementSibling.appendChild(y[c])}var m=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?m.style.width="100%":m.style.minWidth="200px"}else if("boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1)for(c=0;c<2;c++){y=void 0;y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+c}}),e.nextElementSibling.appendChild(y)}else{var y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(y)}this.renderControls(e,r,o,i)},d.prototype.updateValues=function(e,r){var l=e.className.split(" e-")[1],n=parseInt(e.id.slice(-1),2);switch(l){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,l).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=t.getComponent(e,l).value;break;case"datepicker":var o={type:"dateTime",format:this.getColumn(r.field).format||"MM/dd/yyyy"};r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=this.intl.formatDate(t.getComponent(e,l).value,o)}},d.prototype.updateRules=function(e,r,l){for(var n,o,i=t.closest(e,".e-group-container"),s=this.getGroup(i),a=t.closest(e,".e-rule-container"),u=0;a&&null!==a.previousElementSibling;)a=a.previousElementSibling,u++;if(a=t.closest(e,".e-rule-container"),t.closest(e,".e-rule-filter")){n=t.getComponent(e,"dropdownlist"),s.rules[u].field=this.columns[n.index].field,s.rules[u].type=this.columns[n.index].type,s.rules[u].label=this.columns[n.index].label;var p=t.closest(e,".e-rule-filter"),d=p.nextElementSibling.querySelector("input.e-control"),c=t.getComponent(d,"dropdownlist").value;s.rules[u].operator=c,(d=p.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(d=p.nextElementSibling.nextElementSibling.querySelector("div.e-control")),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.updateValues(d,s.rules[u]),this.trigger("fieldChanged",o),this.allowValidation&&s.rules[u].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),s.rules[u].operator=n.value;var h=void 0;e.parentElement;h=a.querySelectorAll(".e-rule-value input.e-control"),o={groupID:i.id,ruleID:a.id,selectedItem:r,cancel:!1},this.allowValidation&&s.rules[u].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),h.length>1&&(s.rules[u].value=[]);for(var m=0;m<h.length;m++)this.updateValues(h[m],s.rules[u]);this.trigger("operatorChanged",o)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,s,u,i,a,l)},d.prototype.ruleValueUpdate=function(e,r,n,o,i,s,a){var u,p=["in","between"];if(null!==r){var d=n.rules[o].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===n.rules[o].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?n.rules[o].value=r:n.rules[o].value=r[0]:n.rules[o].value=r,u={groupID:i.id,ruleID:s.id,selectedItem:r,cancel:!1},this.trigger("valueChanged",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?n.rules[o].value[a]=r:n.rules[o].value=r;else if(e.className.indexOf("e-radio")>-1)n.rules[o].value=r;else if(e.className.indexOf("e-multiselect")>-1)n.rules[o].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(n.rules[o].type,n.rules[o].value=this.processValueString(r,n.rules[o].type)):n.rules[o].value=r;else if(e.className.indexOf("e-datepicker")>-1){var g=t.getInstance(s.querySelector(".e-rule-filter input"),l.DropDownList),v={type:"dateTime",format:this.columns[g.index].format||"MM/dd/yyyy"};v.type&&(p.indexOf(d)>-1?n.rules[o].value[a]=this.intl.formatDate(r,v):n.rules[o].value=this.intl.formatDate(r,v))}this.validatValue(n,o,s)}},d.prototype.validatValue=function(e,r,l){if(this.allowValidation&&e.rules[r].value){var n=l.querySelectorAll(".e-rule-value .e-control");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()}},d.prototype.findGroupByIdx=function(e,t,r){var l=t.rules;if(!r&&l[e]){if((t=l[e]).rules)return t;for(var n=e+1,o=l.length;n<o;n++)if((t=l[n]).rules)return t}return t},d.prototype.destroy=function(){if(this.element){var r,l,n;for(e.prototype.destroy.call(this),n=(r=this.element.querySelectorAll(".e-addrulegroup")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdown-btn").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_e_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){for(var r={groupID:t},l=0,n=e.length;l<n;l++)this.addRuleElement(document.getElementById(t),e[l]);this.trigger("ruleInsert",r)},d.prototype.addGroups=function(e,t){var r=document.getElementById(t),l=this.getGroup(r),n={groupID:t};if(e.length)for(var o=0,i=e.length;o<i;o++)this.importRules(e[o],r);else l.rules.push({condition:"and",rules:[]});this.trigger("groupInsert",n)},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),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(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),l=void 0,n=0;n<r.length;n++)l=r.item(n),t.rippleEffect(l,{selector:".e-btn"})}},d.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"}}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),e.appendChild(r),this.element.appendChild(e)},d.prototype.renderSummaryCollapse=function(){var e=this.createElement("button",{attrs:{class:"e-collapse-rule e-css e-btn e-small"}});e.appendChild(this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-collapse-icon"}})),this.element.querySelector(".e-group-header").appendChild(e)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var l=0,n=Object.keys(e);l<n.length;l++)switch(n[l]){case"summaryView":var o=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content");e.summaryView?(o.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(o.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),o.style.display="block",i.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));break;case"showButtons":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"),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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;break;case"columns":this.columns=e.columns,this.columnSort();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":this.rule=e.rule;break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale}},d.prototype.preRender=function(){this.defaultLocale={StartsWith:"Starts With",EndsWith:"Ends With",Contains:"Contains",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",Empty:"Empty",NotEmpty:"Not Empty",In:"In",NotIn:"Not In",NotContains:"Not Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization,this.groupIdCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{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")}],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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",empty:"Empty",notempty:"NotEmpty",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],l=t?r.length-1:r.length,n=this.rule,o=0;o<l;o++)n=this.findGroupByIdx(r[o],n,0===o);return n},d.prototype.deleteGroup=function(e){var r,l,n=e,o=n.id,i=this.getGroup(n,!0),s=0,a={groupID:o};this.trigger("groupDelete",a);var u=n.nextElementSibling,p=n.previousElementSibling,d=n.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(l=c.length,r=0;r<l;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,l=d.length;r<l;r++)delete this.levelColl[d[r].id];for(;null!==n.previousElementSibling;)n=n.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),i.rules.splice(s,1),delete this.levelColl[o],t.detach(e)},d.prototype.deleteRule=function(e){var r,l=t.closest(e,".e-group-container"),n=this.getGroup(l),o=t.closest(e,".e-rule-container"),i=o,s=o.nextElementSibling,a=o.previousElementSibling,u={groupID:l.id,ruleID:o.id},p=0,d=o.querySelectorAll(".e-tooltip"),c=d.length;for(r=0;r<c;r++)t.getComponent(d[r],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,p++;n.rules.splice(p,1),this.trigger("ruleDelete",u),(!a||a.className.indexOf("e-rule-container")<0)&&s&&t.removeClass([s],"e-joined-rule"),(!s||s.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-prev-joined-rule"),t.detach(i)},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteGroup(document.getElementById(e[t]))},d.prototype.getFilteredRecords=function(){var e=(new n.Query).where(this.getPredicate(this.rule));return new n.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r=e.length;for(t=0;t<r;t++)this.deleteRule(document.getElementById(e[t]))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],l=0,o=Object.keys(this.columns);l<o.length;l++)r.push(this.columns[l].field);return e.rules.length?(new n.Query).select(r).where(t):(new n.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,l,o,i=e.rules,s=!1,a=0,u=i.length;a<u;a++)if(Object.keys(i[a]).indexOf("rules")>-1)(r=this.getPredicate(i[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(i[a].operator.length){var p=i[a].operator.toLowerCase(),d=["equal","notequal"];if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===i[a].type&&d.indexOf(p)>-1,o=this.getColumn(i[a].field),"date"===i[a].type){var c={type:"dateTime",format:o.format||"MM/dd/yyyy"};l=this.intl.parseDate(i[a].value,c)}else l=i[a].value;if(0===a)(p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p?t=this.arrayPredicate(i[a]):""!==(h=l)&&(t=new n.Predicate(i[a].field,i[a].operator,l,s));else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{h=l;t&&""!==h?t=t.and(i[a].field,i[a].operator,l,s):""!==h&&(t=new n.Predicate(i[a].field,i[a].operator,l,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(i[a],t,e.condition);else{var h=l;t&&""!==h?t=t.or(i[a].field,i[a].operator,l,s):""!==h&&(t=new n.Predicate(i[a].field,i[a].operator,l,s))}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,l=0,n=r.length;l<n;l++)r[l].field===e&&(t=r[l]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var l,o=e.value,i=0,s=o.length;i<s;i++)if(""!==o[i])if(0===i)switch(e.operator){case"between":l=new n.Predicate(e.field,"greaterthan",o[i]);break;case"notbetween":l=new n.Predicate(e.field,"lessthan",o[i]);break;case"in":l=new n.Predicate(e.field,"equal",o[i]);break;case"notin":l=new n.Predicate(e.field,"notequal",o[i])}else switch(e.operator){case"between":l=l.and(e.field,"lessthan",o[i]);break;case"notbetween":l=l.or(e.field,"greaterthan",o[i]);break;case"in":l=l.or(e.field,"equal",o[i]);break;case"notin":l=l.and(e.field,"notequal",o[i])}return l&&(t?"and"===r?t=t.and(l):"or"===r&&(t=t.or(l)):t=l),t},d.prototype.importRules=function(e,r,l){l||(r=this.renderGroup(e.condition,r));for(var n=e.rules,o=0,i=n.length;o<i;o++)Object.keys(n[o]).indexOf("rules")>-1?(r=this.renderGroup(n[o].condition,r),r=this.importRules(n[o],r,!0)):this.renderRule(n[o],r);return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var l=e.condition,n=0,o=e.rules.length;n<o;n++){if(e.rules[n].rules)t=this.getSqlString(e.rules[n],t);else{var i=e.rules[n],s="";if(i.value instanceof Array)if("string"==typeof i.value[0]){s+='("'+i.value[0]+'"';for(var a=1,u=i.value.length;a<u;a++)s+=',"'+i.value[a]+'"';s+=")"}else s+="("+i.value+")";else"startswith"===i.operator?s+='("'+i.value+'%")':"endswith"===i.operator?s+='("%'+i.value+'")':"contains"===i.operator?s+='("%'+i.value+'%")':"number"===i.type?s+=i.value:s+='"'+i.value+'"';t+=i.field+" "+this.operators[i.operator]+" "+s}n!==o-1&&(t+=" "+l+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,l=["=","!=","<",">","<=",">="],n=["and","or"],o=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],i=0,s=l.length;i<s;i++)if(t=/^\w+$/.test(l[i])?"\\b":"",new RegExp("^("+l[i]+")"+t,"ig").exec(e))return this.parser.push(["Operators",l[i].toLowerCase()]),l[i].length;for(var i=0,s=n.length;i<s;i++)if(t=/^\w+$/.test(n[i])?"\\b":"",new RegExp("^("+n[i]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",n[i].toLowerCase()]),n[i].length;for(var i=0,s=o.length;i<s;i++)if(t=/^\w+$/.test(o[i])?"\\b":"",new RegExp("^("+o[i]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",o[i].toLowerCase()]),o[i].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.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):1},d.prototype.getOperator=function(e,t){var r={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"};return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":r[t]},d.prototype.processParser=function(e,t,r){for(var l,n,o,i,s,a,u,p,d,c,h=[],m=[],y=0,g=e.length;y<g;y++)if("Literal"===e[y][0]){if(l={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(l.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],o=++y+1,i=g,o=y+1;o<i;o++){if("Right"===e[o][0]){y=o;break}"like"===c&&"String"===e[o][0]?(l.value=e[o][1].replace(/'/g,"").replace(/%/g,""),l.type="string"):"Number"===e[o][0]?h.push(Number(e[o][1])):"String"===e[o][0]&&m.push(e[o][1].replace(/'/g,""))}"like"!==c&&("Number"===e[o-1][0]?(l.value=h,l.type="number"):"String"===e[o-1][0]&&(l.value=m,l.type="string"))}else"Operators"===e[y+1][0]&&(l.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(l.type="number",l.value=Number(e[y+2][1])):(l.type="string",l.value=e[y+2][1].replace(/'/g,"")));t.rules.push(l)}else{if("Left"===e[y][0]){for(n={condition:"",rules:[]},this.parser=e.splice(y+1,g-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(n),n=this.processParser(this.parser,n,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,g-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeConditionChange",void 0),p([t.Event()],d.prototype,"beforeFieldChange",void 0),p([t.Event()],d.prototype,"beforeOperatorChange",void 0),p([t.Event()],d.prototype,"beforeValueChange",void 0),p([t.Event()],d.prototype,"conditionChanged",void 0),p([t.Event()],d.prototype,"fieldChanged",void 0),p([t.Event()],d.prototype,"valueChanged",void 0),p([t.Event()],d.prototype,"operatorChanged",void 0),p([t.Event()],d.prototype,"groupDelete",void 0),p([t.Event()],d.prototype,"ruleDelete",void 0),p([t.Event()],d.prototype,"groupInsert",void 0),p([t.Event()],d.prototype,"ruleInsert",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);return e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej;
this.ej=this.ej||{},this.ej.querybuilder=function(e,t,r,l,n,i,o,s,a){"use strict";var u=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function l(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(l.prototype=r.prototype,new l)}}(),p=function(e,t,r,l){var n,i=arguments.length,o=i<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,r):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,l);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(o=(i<3?n(o):i>3?n(t,r,o):n(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o};l.MultiSelect.Inject(l.CheckBoxSelection);var d=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"values",void 0),p([t.Property(null)],r.prototype,"operators",void 0),p([t.Property(null)],r.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),p([t.Property(null)],r.prototype,"format",void 0),p([t.Property(null)],r.prototype,"step",void 0),r}(t.ChildProperty),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),p([t.Property(null)],r.prototype,"field",void 0),p([t.Property(null)],r.prototype,"label",void 0),p([t.Property(null)],r.prototype,"type",void 0),p([t.Property(null)],r.prototype,"operator",void 0),p([t.Property(null)],r.prototype,"value",void 0),r}(t.ChildProperty),h=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property("and")],r.prototype,"condition",void 0),p([t.Property()],r.prototype,"rules",void 0),r}(t.ChildProperty),m=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return u(r,e),p([t.Property(!0)],r.prototype,"ruleDelete",void 0),p([t.Property(!0)],r.prototype,"groupInsert",void 0),p([t.Property(!0)],r.prototype,"groupDelete",void 0),r}(t.ChildProperty),y=function(e){function d(t,r){return e.call(this,t,r)||this}return u(d,e),d.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},d.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.rule={condition:"and",rules:[]}},d.prototype.getWrapper=function(){return this.element},d.prototype.getModuleName=function(){return"query-builder"},d.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],r=void 0,l=!1,n=void 0,i={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var o=this.columns,s=0,a=o.length;s<a;s++)o[s].type||(e.indexOf(o[s].field)>-1&&("string"===(r=typeof(n=this.dataColl[0][o[s].field]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),o[s].type=r,l=!1),r="string"),o[s].validation||(o[s].validation=i)}else{for(var s=0,a=e.length;s<a;s++)"string"===(r=typeof(n=this.dataColl[0][e[s]]))?l=!isNaN(Date.parse(n)):"object"===r&&(l=n instanceof Date&&!isNaN(n.getTime()),r="string"),t[s]={field:e[s],label:e[s],type:l?"date":r,validation:i},l=!1;this.columns=t}}},d.prototype.triggerEvents=function(e,t){return this.isImportRules?e:("before"===t?this.trigger("beforeChange",e):this.trigger("change",e),e)},d.prototype.clickEventHandler=function(e){var r,l=e.target;this.isImportRules=!1;var n;if("SPAN"===l.tagName&&(l=l.parentElement),l.className.indexOf("e-collapse-rule")>-1){var i=new t.Animation({duration:1e3,delay:0}),o=document.getElementById(this.element.id+"_summary_content"),s=o.querySelector(".e-summary-text");i.animate(".e-query-builder",{name:"SlideLeftIn"}),(u=this.element.querySelector(".e-group-container")).style.display="none",s.textContent=this.getSqlFromRules(this.rule),o.style.display="block",s.style.height=s.scrollHeight+"px"}if("BUTTON"===l.tagName){if(l.className.indexOf("e-removerule")>-1)l.className.indexOf("e-tooltip")>-1&&t.getComponent(l,"tooltip").destroy(),this.deleteRule(l);else if(l.className.indexOf("e-deletegroup")>-1)t.getComponent(l,"tooltip").destroy(),this.deleteGroup(t.closest(l,".e-group-container"));else if(l.className.indexOf("e-edit-rule")>-1)if((i=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);var a=t.extend({},this.rule,{},!0);this.setGroupRules(a),this.renderSummaryCollapse()}else{var u=this.element.querySelector(".e-group-container");u.querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),u.style.display="block"}}else if("LABEL"===l.tagName&&l.parentElement.className.indexOf("e-btn-group")>-1){var p=t.closest(l,".e-group-container");if(n=p.id.replace(this.element.id+"_",""),r={groupID:n,cancel:!1,type:"condition",value:l.textContent.toLowerCase()},(r=this.triggerEvents(r,"before")).cancel)return;var d=this.getGroup(p);d.condition=r.value,this.triggerEvents({groupID:n,type:"condition",value:d.condition})}},d.prototype.selectBtn=function(e,r){"beforeOpen"===r.name?this.showButtons.groupInsert?t.removeClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([r.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):r.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):r.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},d.prototype.addRuleElement=function(e,r){var n={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};if(!(n=this.triggerEvents(n,"before")).cancel){var i=this.ruleElem.cloneNode(!0);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?i.className="e-rule-container e-vertical-mode":i.className="e-rule-container e-horizontal-mode";var o,s,u,p,d,c,h=e.querySelector(".e-rule-list"),m=i.querySelector("button");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?(m.textContent=this.l10n.getConstant("Remove"),t.addClass([m],"e-flat"),t.addClass([m],"e-primary")):(t.addClass([m],"e-round"),t.addClass([m],"e-icon-btn"),new a.Tooltip({content:this.l10n.getConstant("DeleteRule")}).appendTo(m),m=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),i.querySelector("button").appendChild(m)),i.setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.ruleIdCounter++,i.querySelector(".e-filter-input").setAttribute("id",i.id+"_filterkey"),h.appendChild(i),i.previousElementSibling&&i.previousElementSibling.className.indexOf("e-rule-container")>-1&&(i.className.indexOf("e-joined-rule")<0&&(i.className+=" e-joined-rule"),i.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(i.previousElementSibling.className+=" e-prev-joined-rule")),i.previousElementSibling&&i.previousElementSibling.className.indexOf("e-group-container")>-1&&i.className.indexOf("e-separate-rule")<0&&(i.className+=" e-separate-rule"),c=this.element.className.indexOf("e-device")>-1?"250px":"200px",(d=new l.DropDownList({dataSource:this.columns,fields:{text:"label",value:"field"},placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?c:"auto",change:this.changeField.bind(this),value:r?r.field:null})).appendTo("#"+i.id+"_filterkey"),this.filterIndex=d.index,o=this.levelColl[e.id],!this.isImportRules){for(s=this.rule,u=0,p=o.length;u<p;u++)s=this.findGroupByIdx(o[u],s,0===u);Object.keys(r).length?s.rules.push({field:r.field,type:r.type,label:r.label,operator:r.operator,value:r.value}):s.rules.push({field:"",type:"",label:"",operator:"",value:""})}Object.keys(r).length&&this.changeRule(r,{element:d.element,itemData:this.columns[this.filterIndex]}),this.triggerEvents({groupID:e.id.replace(this.element.id+"_",""),type:"insertRule"})}},d.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),position:"BottomCenter",cssClass:"e-querybuilder-error"});t.appendTo(e),t.open(e)},d.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var r=void 0,l=void 0,n=void 0,i=void 0,o=[],s=void 0,a=void 0,u=void 0,p=void 0,d=void 0,c=this.element.querySelectorAll(".e-rule-container"),h=void 0;for(r=0,l=c.length;r<l;r++)if(s=t.closest(c[r],".e-group-container"),d=this.getGroup(s),a=0,i=p=c[r],u=t.getComponent(c[r].querySelector(".e-rule-field input.e-control"),"dropdownlist"),h=!t.isNullOrUndefined(u.index)&&this.columns[u.index].validation,n=p.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;i&&null!==i.previousElementSibling;)i=i.previousElementSibling,a++;if(n=p.querySelector(".e-rule-field input.e-control"),d.rules[a].field||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),n=p.querySelector(".e-rule-operator input.e-control"),d.rules[a].operator||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),d.rules[a].value instanceof Array&&(o=d.rules[a].value),t.isNullOrUndefined(d.rules[a].value)||""===d.rules[a].value||d.rules[a].value instanceof Array&&o.length<1){var m=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var y=0,v=m.length;y<v;y++){var g=m[y],f=void 0;g.parentElement.className.indexOf("e-searcher")>-1?(f=t.closest(g,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(f):m[y].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(m[y].parentElement),y++}}}else u.element&&t.isNullOrUndefined(u.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},d.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)},d.prototype.refreshLevel=function(e){var t,r,l=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,i=l.length,o=0;for(r=0;r<i;r++)(t=l[r]).className.indexOf("e-group-container")>-1&&(e.level.push(o),this.levelColl[t.id]=e.level.slice(),o++,e.groupElement=t,e=this.refreshLevel(e));var s=n.closest(".e-rule-list");return e.groupElement=s?s.closest(".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},d.prototype.groupTemplate=function(){var e,t,r,l,n,i,o,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),r=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),l=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(r),t.appendChild(l),e.appendChild(t),n=this.createElement("div",{attrs:{class:"e-btn-group"}}),(i=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),n.appendChild(i),o=this.createElement("label",{attrs:{class:"e-btn e-btngroup-and-lbl e-small"},innerHTML:"AND"}),n.appendChild(o),i=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),n.appendChild(i),o=this.createElement("label",{attrs:{class:"e-btn e-btngroup-or-lbl e-small"},innerHTML:"OR"}),n.appendChild(o),r.appendChild(n),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),r.appendChild(s),e},d.prototype.ruleTemplate=function(){var e,t,r,l,n,i;return e=this.createElement("div"),n=this.createElement("div",{attrs:{class:"e-rule-field"}}),r=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),r.appendChild(t),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-operator"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value"}}),n.appendChild(r),r=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),i=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",l=this.createElement("button",{attrs:{class:i}}),r.appendChild(l),n.appendChild(r),e.appendChild(n),e},d.prototype.addGroupElement=function(e,l,n,i){var o={groupID:l.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};if(!((o=this.triggerEvents(o,"before")).cancel||this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount)){var u,p=this.groupElem.cloneNode(!0);p.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),this.groupIdCounter++;var d=p.querySelector(".e-btngroup-and"),c=p.querySelector(".e-btngroup-or"),h=p.querySelector(".e-btngroup-and-lbl"),m=p.querySelector(".e-btngroup-or-lbl");if(d.setAttribute("id",this.element.id+"_and"+this.btnGroupId),c.setAttribute("id",this.element.id+"_or"+this.btnGroupId),d.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("name",this.element.id+"_and"+this.btnGroupId),h.setAttribute("for",this.element.id+"_and"+this.btnGroupId),m.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++,e){var y=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";u=this.createElement("button",{attrs:{class:y}}),new r.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(u),new a.Tooltip({content:this.l10n.getConstant("DeleteGroup")}).appendTo(u),t.rippleEffect(u,{selector:".deletegroup"}),p.querySelector(".e-group-action").appendChild(u);for(var v=l.querySelector(".e-rule-list"),g=v.children,f=0,b=0,C=g.length;b<C;b++)g[b].className.indexOf("e-group-container")>-1&&(f+=1);v.appendChild(p);var x=this.levelColl[l.id].slice(0);x.push(f),this.levelColl[p.id]=x,this.isImportRules||(this.addGroups([],l.id.replace(this.element.id+"_","")),i&&this.addRuleElement(p,{}))}else l.appendChild(p),this.levelColl[p.id]=[0];p.querySelector(".e-btngroup-and").setAttribute("checked","true"),"or"===n&&p.querySelector(".e-btngroup-or").setAttribute("checked","true");var E=p.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,E),select:this.selectBtn.bind(this,E)}).appendTo(E),t.rippleEffect(E,{selector:".e-round"}),this.triggerEvents({groupID:l.id.replace(this.element.id+"_",""),type:"insertGroup"})}},d.prototype.notifyChange=function(e,r){for(var l=t.closest(r,".e-rule-value").querySelectorAll(".e-template"),n=[],i=0,o=l.length;i<o;i++)l[i].nextElementSibling&&l[i].nextElementSibling.className.indexOf("e-check")>-1&&n.push(l[i].textContent);this.updateRules(r,l.length>1?n:e)},d.prototype.changeValue=function(e,r){var l,n,i,o;(o=r.event?r.event.target:r.element).className.indexOf("e-day")>-1&&(o=r.element);var s=t.closest(o,".e-group-container"),a=t.closest(o,".e-rule-container");n=s.id.replace(this.element.id+"_",""),i=a.id.replace(this.element.id+"_","");var u=r;u.element&&u.element.className.indexOf("e-datepicker")>-1&&(o=u.element);l={groupID:n,ruleID:i,value:o.className.indexOf("e-radio")>-1?t.getComponent(o,"radio").label:o.className.indexOf("e-multiselect")>-1?t.getComponent(o,"multiselect").value:r.value,cancel:!1,type:"value"},(l=this.triggerEvents(l,"before")).cancel||(this.updateRules(o,l.value,e),this.triggerEvents({groupID:n,ruleID:i,value:l.value,cancel:!1,type:"value"}))},d.prototype.changeField=function(e){if(e.isInteracted){for(var r=t.closest(e.element,".e-group-container"),l=this.getGroup(r),n=t.closest(e.element,".e-rule-container"),i=0;n&&null!==n.previousElementSibling;)n=n.previousElementSibling,i++;this.changeRule(l.rules[i],e)}},d.prototype.changeRule=function(e,r){if(r.itemData){var n,i,o,s,a,u,p,d,c={},h=e.operator?e.operator.toLowerCase():"";u=t.closest(r.element,".e-rule-filter"),p=t.closest(r.element,".e-rule-operator");var m=t.getComponent(r.element,"dropdownlist");s=t.closest(r.element,".e-group-container").id.replace(this.element.id+"_","");var y;if(u){if(i=t.closest(u,".e-rule-container"),a=i.id.replace(this.element.id+"_",""),y={groupID:s,ruleID:a,selectedIndex:m.index,cancel:!1,type:"field"},(y=this.triggerEvents(y,"before")).cancel)return;m.index!==y.selectedIndex&&(m.index=y.selectedIndex),c.type=this.columns[m.index].type,i.querySelector(".e-template")&&(e.value="")}if(p){if(i=t.closest(p,".e-rule-container"),a=i.id.replace(this.element.id+"_",""),y={groupID:s,ruleID:a,selectedIndex:m.index,cancel:!1,type:"operator"},(y=this.triggerEvents(y,"before")).cancel)return;m.index!==y.selectedIndex&&(m.index=y.selectedIndex),c.operator=m.value;var v=c.operator.toLowerCase();if(c.operator.toLowerCase().indexOf("between")>-1||c.operator.toLowerCase().indexOf("in")>-1&&c.operator.toLowerCase().indexOf("contains")<0?(u=p.previousElementSibling,c.type=e.type,e.value=[]):"object"==typeof e.value&&(e.value=e.value.length>0?e.value[0]:""),r.previousItemData){var g=r.previousItemData.value.toLowerCase();(g.indexOf("between")>-1||g.indexOf("in")>-1&&g.indexOf("contains")<0)&&(u=p.previousElementSibling,c.type=e.type)}h.indexOf("in")>-1&&h.indexOf("in")<5&&v.indexOf("in")>-1&&v.indexOf("in")<5&&(u=null)}if(u)if(p=u.nextElementSibling,t.addClass([p],"e-operator"),p.childElementCount)n=t.getComponent(p.querySelector(".e-dropdownlist"),"dropdownlist"),c.operator=n.value,this.renderValues(p,r.itemData,r.previousItemData,!0,e,c,r.element);else{var f=t.closest(p,".e-rule-container").id;d=this.createElement("input",{attrs:{type:"text",id:f+"_operatorkey"}}),p.appendChild(d),this.columns[m.index].operators?o=this.columns[m.index].operators:r.itemData&&(o=this.customOperators[this.columns[m.index].type+"Operator"]);var b=this.element.className.indexOf("e-device")>-1?"250px":"200px";new l.DropDownList({dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:o.length>5?b:"auto",change:this.changeField.bind(this),index:0,value:e?e.operator:null}).appendTo("#"+f+"_operatorkey"),c.operator=e&&""!==e.operator?e.operator:o[0].value,this.isImportRules&&(c.type=this.columns[m.index].type,c.operator=e.operator),this.renderValues(p,this.columns[m.index],r.previousItemData,!1,e,c,r.element)}this.isImportRules||this.updateRules(r.element,r.item)}},d.prototype.destroyControls=function(e){var r;r=e.nextElementSibling.querySelectorAll("input.e-control");var l;l=e.nextElementSibling.querySelectorAll("div.e-control:not(.e-handle)");for(var n=this.columns,i=0,o=r.length;i<o;i++){if(r[i].classList.contains("e-textbox"))t.getComponent(r[i],"textbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[i].id));else if(r[i].classList.contains("e-dropdownlist"))t.getComponent(r[i],"dropdownlist").destroy();else if(r[i].classList.contains("e-radio"))t.getComponent(r[i],"radio").destroy();else if(r[i].classList.contains("e-numerictextbox"))t.getComponent(r[i],"numerictextbox").destroy(),t.detach(e.nextElementSibling.querySelector("input#"+r[i].id));else if(r[i].classList.contains("e-datepicker"))t.getComponent(r[i],"datepicker").destroy();else if(r[i].classList.contains("e-multiselect"))t.getComponent(r[i],"multiselect").destroy();else if(r[i].className.indexOf("e-template")>-1)for(var s=r[i].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],r[i].id);break}document.getElementById(r[i].id)&&t.detach(r[i])}for(var i=0,o=l.length;i<o;i++){if(l[i].className.indexOf("e-template")>-1)for(var s=l[i].className,a=0,u=n.length;a<u;a++)if(n[a].template&&s.indexOf(n[a].field)>-1){this.templateDestroy(n[a],l[i].id);break}t.detach(l[i])}},d.prototype.templateDestroy=function(e,r){var l=e.template.destroy;e.template&&e.template.destroy&&("string"==typeof l?(l=t.getValue(l,window))({elementId:r}):e.template.destroy({elementId:r}))},d.prototype.getDistinctValues=function(e,t){for(var r={},l=[],n=0,i=e.length;n<i;n++){var o=e[n][t];Number(e[n][t])===e[n][t]&&e[n][t]%1!=0&&(o=e[n][t].toString());var s={};o in r||(r[o]=1,s[t]=o,l.push(s))}return l},d.prototype.renderMultiSelect=function(e,t,r,i){var o=this.getDistinctValues(this.dataColl,e.field);new l.MultiSelect({dataSource:new n.DataManager(o),query:new n.Query([e.field]),fields:{text:e.field,value:e.field},value:i,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,r),close:this.closePopup.bind(this,r)}).appendTo("#"+t+"_valuekey"+r)},d.prototype.closePopup=function(e,r){var l=document.getElementById(r.popup.element.id.replace("_popup","")),n=t.getComponent(l,"multiselect").value;this.updateRules(l,n,e)},d.prototype.processTemplate=function(e,r,l,n){var i=t.closest(e,".e-rule-container").querySelectorAll(".e-template");i.length<2?r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:i[0],values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:i[0],values:l.value,operator:n.operator}):r.template&&"string"==typeof r.template.write?t.getValue(r.template.write,window)({elements:i,values:l.value,operator:n.operator}):r.template&&r.template.write&&r.template.write({elements:i,values:l.value,operator:n.operator})},d.prototype.renderStringValue=function(e,t,r,l,n){var o,s=this.isImportRules?t.value:"";if("in"!==r&&"notin"!==r||!this.dataColl.length){"in"!==r&&"notin"!==r||(s=(o=this.isImportRules?t.value:[]).join(","));var a=new i.TextBox({placeholder:"Value",input:this.changeValue.bind(this,l)});a.appendTo("#"+e+"_valuekey"+l),a.value=s,a.dataBind()}else o=this.isImportRules?t.value:[],this.renderMultiSelect(t,e,l,o),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?n.style.width="100%":(n.style.width=null,n.style.minWidth="200px")},d.prototype.renderNumberValue=function(e,r,l,n,o,s,a){var u,p=this.isImportRules?r.value:0;if("in"!==l&&"notin"!==l||!this.dataColl.length)if("in"===l||"notin"===l){var d=(u=this.isImportRules?r.value:[]).join(","),c=new i.TextBox({placeholder:"Value",input:this.changeValue.bind(this,n)});c.appendTo("#"+e+"_valuekey"+n),c.value=d,c.dataBind()}else{var h=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),m=(s=this.columns[h.index]).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,v=s.format?s.format:"n";a>1&&r&&(p=r.value[n]?r.value[n]:0),new i.NumericTextBox({value:p,format:v,min:m,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,n)}).appendTo("#"+e+"_valuekey"+n)}else u=this.isImportRules?r.value:[],this.renderMultiSelect(r,e,n,u),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?o.style.width="100%":(o.style.minWidth="200px",o.style.width=null)},d.prototype.processValueString=function(e,t){var r=[],l=e.split(",");if("string"===t)return l;for(var n=0,i=l.length;n<i;n++)r.push(Number(l[n]));return r},d.prototype.renderControls=function(e,l,n,i){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),l.template)this.processTemplate(e,l,n,i);else{var s="boolean"===i.type||i.operator&&i.operator.toLowerCase().indexOf("between")>-1?2:1,a=t.closest(e,".e-rule-container").id,u=void 0;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"!==i.operator&&"notin"!==i.operator&&(u.style.width="200px");for(var p=0;p<s;p++)switch(i.type){case"string":this.renderStringValue(a,n,i.operator,p,u);break;case"number":this.renderNumberValue(a,n,i.operator,p,u,l,s);break;case"boolean":var d=l.values&&l.values.length?l.values:["True","False"],c=!this.isImportRules||Boolean(n.value);new r.RadioButton({label:d[p],name:a+"default",checked:c,change:this.changeValue.bind(this,p)}).appendTo("#"+a+"_valuekey"+p);break;case"date":var h=new Date,m=void 0;if(this.isImportRules&&n&&n.value){h=s>1?new Date(n.value[p]):new Date(n.value);var y=void 0,v=this.getColumn(n.field);if(m=s>1?n.value[p]:n.value,v.format){var g=this.intl.getDateParser({skeleton:"full",type:"dateTime"});y={type:"dateTime",format:v.format},"Invalid Date"===h.toLocaleDateString()&&(h=g(m),t.isNullOrUndefined(h)&&(h=this.intl.parseDate(m,y)))}}(l.format?new o.DatePicker({value:h,format:l.format,change:this.changeValue.bind(this,p)}):new o.DatePicker({value:h,change:this.changeValue.bind(this,p)})).appendTo("#"+a+"_valuekey"+p)}}}},d.prototype.renderValues=function(e,r,l,n,i,o,s){if(n){var a=t.getComponent(e.querySelector("input"),"dropdownlist");r.operators?(a.dataSource=r.operators,a.index=0!==a.index?0:1,a.dataBind(),o.operator=a.value):r.type&&(a.dataSource=this.customOperators[r.type+"Operator"],a.index=0!==a.index?0:1,a.dataBind(),o.operator=a.value)}var u=t.closest(e,".e-rule-container").id;l&&l.template&&(this.templateDestroy(l,u+"_valuekey0"),t.detach(e.nextElementSibling.querySelector("#"+u+"_valuekey0"))),n&&this.destroyControls(e);var p=document.getElementById(s.id.replace("operatorkey","filterkey")),d=t.getComponent(p,"dropdownlist");if(r.template=this.columns[d.index].template,r.template){r.template=this.columns[d.index].template;y=void 0;if(r.template&&"string"==typeof r.template.create?y=t.getValue(r.template.create,window)():r.template&&r.template.create&&(y=r.template.create()),y instanceof Element)y.id=u+"_valuekey0",t.addClass([y],"e-template"),t.addClass([y],"e-"+r.field),e.nextElementSibling.appendChild(y);else if(y instanceof Array){t.addClass(y,"e-template");for(var c=0,h=y.length;c<h;c++)y[c].id=u+"_valuekey"+c,e.nextElementSibling.appendChild(y[c])}var m=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?m.style.width="100%":m.style.minWidth="200px"}else if("boolean"===o.type||o.operator&&o.operator.toLowerCase().indexOf("between")>-1)for(c=0;c<2;c++){y=void 0;y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey"+c}}),e.nextElementSibling.appendChild(y)}else{var y=this.createElement("input",{attrs:{type:"text",id:u+"_valuekey0"}});e.nextElementSibling.appendChild(y)}this.renderControls(e,r,i,o)},d.prototype.updateValues=function(e,r){var l=e.className.split(" e-")[1],n=parseInt(e.id.slice(-1),2);switch(l){case"textbox":case"dropdownlist":case"radio":r.value=t.getComponent(e,l).value;break;case"numerictextbox":r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:r.value=t.getComponent(e,l).value;break;case"datepicker":var i={type:"dateTime",format:this.getColumn(r.field).format};r.operator.indexOf("between")>-1?r.value[n]=t.getComponent(e,l).value:t.isNullOrUndefined(i.format)?r.value=this.intl.formatDate(t.getComponent(e,l).value):r.value=this.intl.formatDate(t.getComponent(e,l).value,i)}},d.prototype.updateRules=function(e,r,l){for(var n,i,o,s=t.closest(e,".e-group-container"),a=this.getGroup(s),u=t.closest(e,".e-rule-container"),p=0,d=s.id.replace(this.element.id+"_","");u&&null!==u.previousElementSibling;)u=u.previousElementSibling,p++;if(u=t.closest(e,".e-rule-container"),o=u.id.replace(this.element.id+"_",""),t.closest(e,".e-rule-filter")){n=t.getComponent(e,"dropdownlist"),a.rules[p].field=this.columns[n.index].field,a.rules[p].type=this.columns[n.index].type,a.rules[p].label=this.columns[n.index].label;var c=t.closest(e,".e-rule-filter"),h=c.nextElementSibling.querySelector("input.e-control"),m=t.getComponent(h,"dropdownlist").value;a.rules[p].operator=m,(h=c.nextElementSibling.nextElementSibling.querySelector("input.e-control"))||(h=c.nextElementSibling.nextElementSibling.querySelector("div.e-control")),i={groupID:d,ruleID:o,value:a.rules[p].field,type:"field"},this.updateValues(h,a.rules[p]),this.triggerEvents(i),this.allowValidation&&a.rules[p].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy()}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),a.rules[p].operator=n.value;var y=void 0;e.parentElement;y=u.querySelectorAll(".e-rule-value input.e-control"),i={groupID:d,ruleID:o,value:n.value,type:"operator"},this.allowValidation&&a.rules[p].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),y.length>1&&(a.rules[p].value=[]);for(var v=0;v<y.length;v++)this.updateValues(y[v],a.rules[p]);this.triggerEvents(i)}else t.closest(e,".e-rule-value")&&this.ruleValueUpdate(e,r,a,p,s,u,l)},d.prototype.ruleValueUpdate=function(e,r,n,i,o,s,a){var u,p=["in","between","notin","notbetween"];if(null!==r){var d=n.rules[i].operator.toLowerCase();if(e.className.indexOf("e-multiselect")>-1&&"number"===n.rules[i].type){for(var c=[],h=r,m=0,y=h.length;m<y;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(r=c)}if(e.className.indexOf("e-template")>-1)r instanceof Array?p.indexOf(d)>-1?n.rules[i].value=r:n.rules[i].value=r[0]:n.rules[i].value=r,u={groupID:o.id,ruleID:s.id,value:n.rules[i].value,type:"value"},this.triggerEvents(u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?n.rules[i].value[a]=r:n.rules[i].value=r;else if(e.className.indexOf("e-radio")>-1)n.rules[i].value=r;else if(e.className.indexOf("e-multiselect")>-1)n.rules[i].value=r;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(n.rules[i].type,n.rules[i].value=this.processValueString(r,n.rules[i].type)):n.rules[i].value=r;else if(e.className.indexOf("e-datepicker")>-1){var v=t.getInstance(s.querySelector(".e-rule-filter input"),l.DropDownList),g={type:"dateTime",format:this.columns[v.index].format||"MM/dd/yyyy"};g.type&&(p.indexOf(d)>-1?n.rules[i].value[a]=this.intl.formatDate(r,g):n.rules[i].value=this.intl.formatDate(r,g))}this.validatValue(n,i,s)}},d.prototype.validatValue=function(e,r,l){if(this.allowValidation&&e.rules[r].value){var n=l.querySelectorAll(".e-rule-value .e-control");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()}},d.prototype.findGroupByIdx=function(e,t,r){var l=t.rules,n=[];if(!r){for(var i=0,o=l.length;i<o;i++)(t=l[i]).rules&&n.push(t);return n[e]}return t},d.prototype.destroy=function(){if(this.element){var r,l,n;for(e.prototype.destroy.call(this),n=(r=this.element.querySelectorAll(".e-addrulegroup")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdown-btn").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-filter .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);for(n=(r=this.element.querySelectorAll(".e-rule-operator .e-control")).length,l=0;l<n;l++)t.getComponent(r[l],"dropdownlist").destroy(),t.detach(r[l]);this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.rule={condition:"and",rules:[]},this.element.innerHTML="",t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},d.prototype.addRules=function(e,t){t=this.element.id+"_"+t;for(var r=0,l=e.length;r<l;r++)this.addRuleElement(document.getElementById(t),e[r])},d.prototype.addGroups=function(e,t){t=this.element.id+"_"+t;var r=document.getElementById(t),l=this.getGroup(r);if(e.length)for(var n=0,i=e.length;n<i;n++)this.importRules(e[n],r);else l.rules.push({condition:"and",rules:[]})},d.prototype.initWrapper=function(){if(this.cssClass&&t.addClass([this.element],this.cssClass),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(document.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(document.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.isImportRules&&this.summaryView)this.renderSummary();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition);var e=t.extend({},this.rule,{},!0);this.setGroupRules(e)}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});for(var r=document.querySelectorAll("label.e-btn"),l=void 0,n=0;n<r.length;n++)l=r.item(n),t.rippleEffect(l,{selector:".e-btn"})}},d.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"}),r=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),l=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),r.textContent=this.l10n.getConstant("Edit"),l.appendChild(r),e.appendChild(l),this.element.appendChild(e)},d.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)},d.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new n.DataManager(this.columns).executeLocal((new n.Query).sortBy("field")))},d.prototype.onPropertyChanged=function(e,r){for(var l=0,n=Object.keys(e);l<n.length;l++)switch(n[l]){case"summaryView":var i=this.element.querySelector(".e-group-container"),o=this.element.querySelector(".e-summary-content");e.summaryView?(i.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),o=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),o.style.display="block"):(i.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),i.style.display="block",o.style.display="none");break;case"displayMode":"Horizontal"===e.displayMode?(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode")):(t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"));break;case"showButtons":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"),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":r.cssClass&&t.removeClass([this.element],r.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.element],"e-rtl"):t.removeClass([this.element],"e-rtl");break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource;break;case"columns":this.columns=e.columns,this.columnSort();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":this.rule=e.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)}},d.prototype.preRender=function(){this.defaultLocale={StartsWith:"Starts With",EndsWith:"Ends With",Contains:"Contains",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"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization(this.locale),this.groupIdCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{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")}],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")}],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"},this.operatorValue={equal:"Equal",greaterthan:"GreaterThan",greaterthanorequal:"GreaterThanOrEqual",lessthan:"LessThan",lessthanorequal:"LessThanOrEqual",notequal:"NotEqual",between:"Between",in:"in",notin:"NotIn",notbetween:"NotBetween",startswith:"StartsWith",endswith:"EndsWith",contains:"Contains"}},d.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(),this.dataSource instanceof n.DataManager?(this.dataManager=this.dataSource,this.executeDataManager(new n.Query)):(this.dataManager=new n.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new n.Query),this.initControl())},d.prototype.executeDataManager=function(e){var t=this,r=this.dataManager.executeQuery(e),l=new n.Deferred;r.then(function(e){t.dataColl=e.result,t.initControl()}).catch(function(e){l.reject(e)})},d.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},d.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this)},d.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler)},d.prototype.getGroup=function(e,t){for(var r=this.levelColl[e.id],l=t?r.length-1:r.length,n=this.rule,i=0;i<l;i++)n=this.findGroupByIdx(r[i],n,0===i);return n},d.prototype.deleteGroup=function(e){var r,l,n=e,i=n.id.replace(this.element.id+"_",""),o=this.getGroup(n,!0),s=0,a={groupID:i,cancel:!1,type:"deleteGroup"};if(!(a=this.triggerEvents(a,"before")).cancel){var u=n.nextElementSibling,p=n.previousElementSibling,d=n.querySelectorAll(".e-group-container"),c=e.querySelectorAll(".e-tooltip");for(l=c.length,r=0;r<l;r++)t.getComponent(c[r],"tooltip").destroy();for(r=0,l=d.length;r<l;r++)delete this.levelColl[d[r].id];for(;null!==n.previousElementSibling;)n=n.previousElementSibling,s++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),p&&p.className.indexOf("e-rule-container")>-1&&t.addClass([p],"e-prev-joined-rule")),o.rules.splice(s,1),delete this.levelColl[i],t.detach(e),this.refreshLevelColl(),this.triggerEvents(a)}},d.prototype.deleteRule=function(e){var r,l,n=t.closest(e,".e-group-container"),i=this.getGroup(n),o=t.closest(e,".e-rule-container"),s={groupID:l=n.id.replace(this.element.id+"_",""),ruleID:r=e.closest(".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};if(!(s=this.triggerEvents(s,"before")).cancel){var a,u=o,p=o.nextElementSibling,d=o.previousElementSibling,c=0,h=o.querySelectorAll(".e-tooltip"),m=h.length;for(a=0;a<m;a++)t.getComponent(h[a],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,c++;i.rules.splice(c,1),(!d||d.className.indexOf("e-rule-container")<0)&&p&&t.removeClass([p],"e-joined-rule"),(!p||p.className.indexOf("e-rule-container")<0)&&d&&t.removeClass([d],"e-prev-joined-rule"),t.detach(u),this.triggerEvents(s)}},d.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},d.prototype.setRules=function(e){var r=t.extend({},e,{},!0);this.setGroupRules(r)},d.prototype.getRules=function(){return this.rule},d.prototype.deleteGroups=function(e){var t,r,l=e.length;for(t=0;t<l;t++)r=this.element.id+"_"+e[t],this.deleteGroup(document.getElementById(r))},d.prototype.getFilteredRecords=function(){var e=(new n.Query).where(this.getPredicate(this.rule));return new n.DataManager(this.dataSource).executeLocal(e)},d.prototype.deleteRules=function(e){var t,r,l=e.length;for(t=0;t<l;t++)r=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(r))},d.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),r=[],l=0,i=Object.keys(this.columns);l<i.length;l++)r.push(this.columns[l].field);return e.rules.length?(new n.Query).select(r).where(t):(new n.Query).select(r)},d.prototype.getPredicate=function(e){for(var t,r,l,i,o=e.rules,s=!1,a=0,u=o.length;a<u;a++)if(Object.keys(o[a]).indexOf("rules")>-1)(r=this.getPredicate(o[a]))&&(t=t?"and"===e.condition?t.and(r):t.or(r):r);else if(o[a].operator.length){var p=o[a].operator.toLowerCase(),d=["equal","notequal"];if(s=["contains","startswith","endswith"].indexOf(p)>-1||"date"===o[a].type&&d.indexOf(p)>-1,i=this.getColumn(o[a].field),"date"===o[a].type){var c={type:"dateTime",format:i.format||"MM/dd/yyyy"};l=this.intl.parseDate(o[a].value,c)}else l=o[a].value;if(0===a)(p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p?t=this.arrayPredicate(o[a]):""!==(h=l)&&(t=new n.Predicate(o[a].field,o[a].operator,l,s));else if("and"===e.condition)if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(o[a],t,e.condition);else{h=l;t&&""!==h?t=t.and(o[a].field,o[a].operator,l,s):""!==h&&(t=new n.Predicate(o[a].field,o[a].operator,l,s))}else if((p.indexOf("in")>-1||p.indexOf("between")>-1)&&"contains"!==p)t=this.arrayPredicate(o[a],t,e.condition);else{var h=l;t&&""!==h?t=t.or(o[a].field,o[a].operator,l,s):""!==h&&(t=new n.Predicate(o[a].field,o[a].operator,l,s))}}return t},d.prototype.getColumn=function(e){for(var t,r=this.columns,l=0,n=r.length;l<n;l++)r[l].field===e&&(t=r[l]);return t},d.prototype.arrayPredicate=function(e,t,r){for(var l,i=e.value,o=0,s=i.length;o<s;o++)if(""!==i[o])if(0===o)switch(e.operator){case"between":l=new n.Predicate(e.field,"greaterthan",i[o]);break;case"notbetween":l=new n.Predicate(e.field,"lessthan",i[o]);break;case"in":l=new n.Predicate(e.field,"equal",i[o]);break;case"notin":l=new n.Predicate(e.field,"notequal",i[o])}else switch(e.operator){case"between":l=l.and(e.field,"lessthan",i[o]);break;case"notbetween":l=l.or(e.field,"greaterthan",i[o]);break;case"in":l=l.or(e.field,"equal",i[o]);break;case"notin":l=l.and(e.field,"notequal",i[o])}return l&&(t?"and"===r?t=t.and(l):"or"===r&&(t=t.or(l)):t=l),t},d.prototype.importRules=function(e,r,l){l||(r=this.renderGroup(e.condition,r));var n=e.rules;if(!t.isNullOrUndefined(n))for(var i=0,o=n.length;i<o;i++){var s=Object.keys(n[i]);!t.isNullOrUndefined(n[i].rules)&&s.indexOf("rules")>-1?(r=this.renderGroup(n[i].condition,r),r=this.importRules(n[i],r,!0)):this.renderRule(n[i],r)}return(r=t.closest(r,".e-rule-list"))&&(r=t.closest(r,".e-group-container")),r},d.prototype.renderGroup=function(e,t){this.addGroupElement(!0,t,e);var r=t.querySelectorAll(".e-group-container");return r[r.length-1]},d.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},d.prototype.getSqlString=function(e,t){var r=!1;t?t+="(":(t="",r=!0);for(var l=e.condition,n=0,i=e.rules.length;n<i;n++){if(e.rules[n].rules)t=this.getSqlString(e.rules[n],t);else{var o=e.rules[n],s="";if(o.value instanceof Array)if(o.operator.indexOf("between")>-1)s+=o.value[0]+" AND "+o.value[1];else if("string"==typeof o.value[0]){s+='("'+o.value[0]+'"';for(var a=1,u=o.value.length;a<u;a++)s+=',"'+o.value[a]+'"';s+=")"}else s+="("+o.value+")";else"startswith"===o.operator?s+='("'+o.value+'%")':"endswith"===o.operator?s+='("%'+o.value+'")':"contains"===o.operator?s+='("%'+o.value+'%")':"number"===o.type?s+=o.value:s+='"'+o.value+'"';t+=o.field+" "+this.operators[o.operator]+" "+s}n!==i-1&&(t+=" "+l+" ")}return r||(t+=")"),t},d.prototype.setRulesFromSql=function(e){var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,rules:t.rules})},d.prototype.getRulesFromSql=function(e){return this.parser=[],this.sqlParser(e),this.rule={condition:"",rules:[]},this.processParser(this.parser,this.rule,[0])},d.prototype.getSqlFromRules=function(e){return this.getSqlString(e).replace(/"/g,"'")},d.prototype.sqlParser=function(e){var t,r=0;do{t=e.slice(r),r+=this.parseSqlStrings(t)}while(""!==t);return this.parser},d.prototype.parseSqlStrings=function(e){for(var t,r,l=["=","!=","<",">","<=",">="],n=["and","or"],i=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN"],o=0,s=l.length;o<s;o++)if(t=/^\w+$/.test(l[o])?"\\b":"",new RegExp("^("+l[o]+")"+t,"ig").exec(e))return this.parser.push(["Operators",l[o].toLowerCase()]),l[o].length;for(var o=0,s=n.length;o<s;o++)if(t=/^\w+$/.test(n[o])?"\\b":"",new RegExp("^("+n[o]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",n[o].toLowerCase()]),n[o].length;for(var o=0,s=i.length;o<s;o++)if(t=/^\w+$/.test(i[o])?"\\b":"",new RegExp("^("+i[o]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",i[o].toLowerCase()]),i[o].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(r=/^`?([a-z_][a-z0-9_]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",r]),r.length):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(r=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",r]),r.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.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):1},d.prototype.getOperator=function(e,t){var r={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween"};return 0===e.indexOf("%")&&e.indexOf("%")===e.length-1?"contains":0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"startswith":0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"endswith":r[t]},d.prototype.processParser=function(e,t,r){for(var l,n,i,o,s,a,u,p,d,c,h=[],m=[],y=0,v=e.length;y<v;y++)if("Literal"===e[y][0]){if(l={label:e[y][1],field:e[y][1]},"SubOperators"===e[y+1][0]){for(l.operator=this.getOperator(e[y+3][1].replace(/'/g,""),e[y+1][1]),c=e[y+1][1],i=++y+1,o=v,i=y+1;i<o;i++){if("Right"===e[i][0]){y=i;break}if("like"===c&&"String"===e[i][0])l.value=e[i][1].replace(/'/g,"").replace(/%/g,""),l.type="string";else if("between"===c){if("Literal"===e[i][0]||"Left"===e[i][0])break;"Number"===e[i][0]&&h.push(Number(e[i][1]))}else"Number"===e[i][0]?h.push(Number(e[i][1])):"String"===e[i][0]&&m.push(e[i][1].replace(/'/g,""))}"like"!==c&&("Number"===e[i-1][0]?(l.value=h,l.type="number"):"String"===e[i-1][0]?(l.value=m,l.type="string"):"between"===c&&"Conditions"===e[i-1][0]&&(l.value=h,l.type="number"))}else"Operators"===e[y+1][0]&&(l.operator=this.getOperator(e[y+2][1],e[y+1][1]),"Number"===e[y+2][0]?(l.type="number",l.value=Number(e[y+2][1])):(l.type="string",l.value=e[y+2][1].replace(/'/g,"")));t.rules.push(l)}else{if("Left"===e[y][0]){for(n={condition:"",rules:[]},this.parser=e.splice(y+1,v-(y+1)),d=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&d++;return r.push(d),t.rules.push(n),n=this.processParser(this.parser,n,r),t}if("Conditions"===e[y][0])t.condition=e[y][1];else if("Right"===e[y][0]){for(this.parser=e.splice(y+1,v-(y+1)),r.pop(),t=this.rule,p=r.length,u=0;u<p;u++)t=this.findGroupByIdx(r[u],t,0===u);return this.processParser(this.parser,t,r)}}return t},p([t.Event()],d.prototype,"created",void 0),p([t.Event()],d.prototype,"beforeChange",void 0),p([t.Event()],d.prototype,"change",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],d.prototype,"showButtons",void 0),p([t.Property(!1)],d.prototype,"summaryView",void 0),p([t.Property(!1)],d.prototype,"allowValidation",void 0),p([t.Property([])],d.prototype,"columns",void 0),p([t.Property("")],d.prototype,"cssClass",void 0),p([t.Property([])],d.prototype,"dataSource",void 0),p([t.Property("Horizontal")],d.prototype,"displayMode",void 0),p([t.Property(!1)],d.prototype,"enableRtl",void 0),p([t.Property(!1)],d.prototype,"enablePersistence",void 0),p([t.Property("Default")],d.prototype,"sortDirection",void 0),p([t.Property(5)],d.prototype,"maxGroupCount",void 0),p([t.Property("auto")],d.prototype,"height",void 0),p([t.Property("auto")],d.prototype,"width",void 0),p([t.Complex({condition:"and",rules:[]},h)],d.prototype,"rule",void 0),d=p([t.NotifyPropertyChanges],d)}(t.Component);return e.Columns=d,e.Rules=c,e.Rule=h,e.ShowButtons=m,e.QueryBuilder=y,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej;
//# sourceMappingURL=ej2-querybuilder.min.js.map
/*!
* filename: index.d.ts
* version : 17.1.1-beta
* version : 17.1.32-beta
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.

@@ -5,0 +5,0 @@ * Use of this code is subject to the terms of our license.

{
"name": "@syncfusion/ej2-querybuilder",
"version": "17.1.1-beta",
"version": "17.1.32-beta",
"description": "Essential JS 2 QueryBuilder",

@@ -11,18 +11,10 @@ "author": "Syncfusion Inc.",

"dependencies": {
"@syncfusion/ej2-base": "~17.1.1-beta",
"@syncfusion/ej2-buttons": "~17.1.1-beta",
"@syncfusion/ej2-calendars": "~17.1.1-beta",
"@syncfusion/ej2-dropdowns": "~17.1.1-beta",
"@syncfusion/ej2-splitbuttons": "~17.1.1-beta",
"@syncfusion/ej2-inputs": "~17.1.1-beta"
"@syncfusion/ej2-base": "~17.1.32-beta",
"@syncfusion/ej2-buttons": "~17.1.32-beta",
"@syncfusion/ej2-calendars": "~17.1.32-beta",
"@syncfusion/ej2-dropdowns": "~17.1.32-beta",
"@syncfusion/ej2-splitbuttons": "~17.1.32-beta",
"@syncfusion/ej2-inputs": "~17.1.32-beta"
},
"devDependencies": {
"@syncfusion/ej2-grids": "*",
"json-sql": "^0.4.11",
"@types/chai": "^3.4.28",
"@types/es6-promise": "0.0.28",
"@types/jasmine": "2.8.9",
"@types/jasmine-ajax": "^3.1.27",
"@types/requirejs": "^2.1.26"
},
"devDependencies": {},
"keywords": [

@@ -37,2 +29,8 @@ "ej2",

"ej2-querybuilder",
"js querybuilder",
"js query builder",
"query builder js",
"query builder",
"javascript querybuilder",
"typescript querybuilder",
"querybuilder"

@@ -39,0 +37,0 @@ ],

@@ -1,3 +0,3 @@

import { Component, INotifyPropertyChanged, NotifyPropertyChanges, getComponent, MouseEventArgs, Browser } from '@syncfusion/ej2-base';import { Property, ChildProperty, Complex, L10n, closest, extend, isNullOrUndefined } from '@syncfusion/ej2-base';import { getInstance, addClass, removeClass, rippleEffect, detach, classList } from '@syncfusion/ej2-base';import { Internationalization, DateFormatOptions } from '@syncfusion/ej2-base';import { Button, RadioButton, ChangeEventArgs as ButtonChangeEventArgs } from '@syncfusion/ej2-buttons';import { DropDownList, ChangeEventArgs, FieldSettingsModel, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';import { MultiSelect, MultiSelectChangeEventArgs } from '@syncfusion/ej2-dropdowns';import { EmitType, Event, EventHandler, getValue } from '@syncfusion/ej2-base';import { Query, Predicate, DataManager } from '@syncfusion/ej2-data';import { TextBox, NumericTextBox, InputEventArgs, ChangeEventArgs as InputChangeEventArgs } from '@syncfusion/ej2-inputs';import { DatePicker, ChangeEventArgs as CalendarChangeEventArgs } from '@syncfusion/ej2-calendars';import { DropDownButton, ItemModel, MenuEventArgs } from '@syncfusion/ej2-splitbuttons';import { Tooltip } from '@syncfusion/ej2-popups';
import {TemplateColumn,Validation,DisplayMode,SortDirection} from "./query-builder";
import { Component, INotifyPropertyChanged, NotifyPropertyChanges, getComponent, MouseEventArgs, Browser } from '@syncfusion/ej2-base';import { Property, ChildProperty, Complex, L10n, closest, extend, isNullOrUndefined } from '@syncfusion/ej2-base';import { getInstance, addClass, removeClass, rippleEffect, detach, classList } from '@syncfusion/ej2-base';import { Internationalization, DateFormatOptions } from '@syncfusion/ej2-base';import { Button, RadioButton, ChangeEventArgs as ButtonChangeEventArgs } from '@syncfusion/ej2-buttons';import { DropDownList, ChangeEventArgs as DropDownChangeEventArgs, FieldSettingsModel, CheckBoxSelection } from '@syncfusion/ej2-dropdowns';import { MultiSelect, MultiSelectChangeEventArgs, PopupEventArgs } from '@syncfusion/ej2-dropdowns';import { EmitType, Event, EventHandler, getValue, Animation, BaseEventArgs } from '@syncfusion/ej2-base';import { Query, Predicate, DataManager, Deferred } from '@syncfusion/ej2-data';import { TextBox, NumericTextBox, InputEventArgs, ChangeEventArgs as InputChangeEventArgs } from '@syncfusion/ej2-inputs';import { DatePicker, ChangeEventArgs as CalendarChangeEventArgs } from '@syncfusion/ej2-calendars';import { DropDownButton, ItemModel, MenuEventArgs } from '@syncfusion/ej2-splitbuttons';import { Tooltip } from '@syncfusion/ej2-popups';
import {TemplateColumn,Validation,ChangeEventArgs,DisplayMode,SortDirection} from "./query-builder";
import {ComponentModel} from '@syncfusion/ej2-base';

@@ -168,77 +168,17 @@

     */
created?: EmitType<Object>;
created?: EmitType<Event>;
/**
* Triggers before the condition (And/Or) is changed.
* Triggers before the condition (And/Or), field, operator, value is changed.
* @event
*/
beforeConditionChange?: EmitType<Object>;
beforeChange?: EmitType<ChangeEventArgs>;
/**
* Triggers before the field is changed.
* Triggers when changing the condition(AND/OR), field, value, operator is changed
* @event
*/
beforeFieldChange?: EmitType<Object>;
change?: EmitType<ChangeEventArgs>;
/**
* Triggers before the operator is changed. (e.g., equal, less etc.).
* @event
*/
beforeOperatorChange?: EmitType<Object>;
/**
* Triggers before the value is changed.
* @event
*/
beforeValueChange?: EmitType<Object>;
/**
* Triggers when changing the condition(AND/OR) in button group.
* @event
*/
conditionChanged?: EmitType<Object>;
/**
* Triggers when changing the fields using the drop-down list.
* @event
*/
fieldChanged?: EmitType<Object>;
/**
* Triggers when changing the rule value.
* @event
*/
valueChanged?: EmitType<Object>;
/**
* Triggers when changing the operator value.
* @event
*/
operatorChanged?: EmitType<Object>;
/**
* Triggers when deleting a group.
* @event
*/
groupDelete?: EmitType<Object>;
/**
* Triggers when deleting the rule.
* @event
*/
ruleDelete?: EmitType<Object>;
/**
* Triggers when adding a Group.
* @event
*/
groupInsert?: EmitType<Object>;
/**
* Triggers when adding the rule.
* @event
*/
ruleInsert?: EmitType<Object>;
/**
* Specifies the showButtons settings of the query builder component.

@@ -280,3 +220,3 @@ * The showButtons can be enable Enables or disables the ruleDelete, groupInsert, and groupDelete buttons.

*/
dataSource?: Object[];
dataSource?: Object[] | Object | DataManager;

@@ -283,0 +223,0 @@ /**

@@ -7,4 +7,4 @@ /**

import { QueryBuilderModel, ShowButtonsModel, ColumnsModel, RulesModel, RuleModel } from './query-builder-model';
import { EmitType } from '@syncfusion/ej2-base';
import { Query, Predicate } from '@syncfusion/ej2-data';
import { EmitType, BaseEventArgs } from '@syncfusion/ej2-base';
import { Query, Predicate, DataManager } from '@syncfusion/ej2-data';
export declare class Columns extends ChildProperty<Columns> {

@@ -163,2 +163,4 @@ /**

private groupElem;
private dataColl;
private dataManager;
/**

@@ -168,64 +170,14 @@ * Triggers when the component is created.

*/
created: EmitType<Object>;
created: EmitType<Event>;
/**
* Triggers before the condition (And/Or) is changed.
* Triggers before the condition (And/Or), field, operator, value is changed.
* @event
*/
beforeConditionChange: EmitType<Object>;
beforeChange: EmitType<ChangeEventArgs>;
/**
* Triggers before the field is changed.
* Triggers when changing the condition(AND/OR), field, value, operator is changed
* @event
*/
beforeFieldChange: EmitType<Object>;
change: EmitType<ChangeEventArgs>;
/**
* Triggers before the operator is changed. (e.g., equal, less etc.).
* @event
*/
beforeOperatorChange: EmitType<Object>;
/**
* Triggers before the value is changed.
* @event
*/
beforeValueChange: EmitType<Object>;
/**
* Triggers when changing the condition(AND/OR) in button group.
* @event
*/
conditionChanged: EmitType<Object>;
/**
* Triggers when changing the fields using the drop-down list.
* @event
*/
fieldChanged: EmitType<Object>;
/**
* Triggers when changing the rule value.
* @event
*/
valueChanged: EmitType<Object>;
/**
* Triggers when changing the operator value.
* @event
*/
operatorChanged: EmitType<Object>;
/**
* Triggers when deleting a group.
* @event
*/
groupDelete: EmitType<Object>;
/**
* Triggers when deleting the rule.
* @event
*/
ruleDelete: EmitType<Object>;
/**
* Triggers when adding a Group.
* @event
*/
groupInsert: EmitType<Object>;
/**
* Triggers when adding the rule.
* @event
*/
ruleInsert: EmitType<Object>;
/**
* Specifies the showButtons settings of the query builder component.

@@ -262,3 +214,3 @@ * The showButtons can be enable Enables or disables the ruleDelete, groupInsert, and groupDelete buttons.

*/
dataSource: Object[];
dataSource: Object[] | Object | DataManager;
/**

@@ -316,2 +268,3 @@ * Specifies the displayMode as Horizontal or Vertical.

private initialize;
private triggerEvents;
private clickEventHandler;

@@ -326,2 +279,4 @@ private selectBtn;

validateFields(): boolean;
private refreshLevelColl;
private refreshLevel;
private groupTemplate;

@@ -338,2 +293,3 @@ private ruleTemplate;

private renderMultiSelect;
private closePopup;
private processTemplate;

@@ -374,2 +330,4 @@ private renderStringValue;

protected render(): void;
private executeDataManager;
private initControl;
protected wireEvents(): void;

@@ -395,3 +353,3 @@ protected unWireEvents(): void;

*/
deleteGroups(groupID: string[]): void;
deleteGroups(groupIdColl: string[]): void;
/**

@@ -406,3 +364,3 @@ * Gets the predicate from collection of rules.

*/
deleteRules(ruleID: string[]): void;
deleteRules(ruleIdColl: string[]): void;
/**

@@ -480,1 +438,12 @@ * Gets the query for Data Manager.

}
/**
* Interface for change event.
*/
export interface ChangeEventArgs extends BaseEventArgs {
groupID: string;
ruleID?: string;
value?: string | number | Date | boolean | string[];
selectedIndex?: number;
cancel?: boolean;
type?: string;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc