@easyquery/core 7.2.4-rc01 → 7.2.4-rc03
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/easyquery.core.js +41 -9
- package/dist/bundles/easyquery.core.js.map +1 -1
- package/dist/bundles/easyquery.core.min.js +1 -1
- package/dist/bundles/easyquery.core.min.js.map +1 -1
- package/dist/lib/common/eq_services.js +1 -1
- package/dist/lib/common/eq_services.js.map +1 -1
- package/dist/lib/eqs/eqs_exporter.js.map +1 -1
- package/dist/lib/main/context.js +6 -5
- package/dist/lib/main/context.js.map +1 -1
- package/dist/lib/main/context_options.d.ts +1 -0
- package/dist/lib/main/query_storage.js +1 -1
- package/dist/lib/main/query_storage.js.map +1 -1
- package/dist/lib/query/query.d.ts +5 -0
- package/dist/lib/query/query.js +33 -2
- package/dist/lib/query/query.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("easyqueryCore",[],e):"object"==typeof exports?exports.easyqueryCore=e():t.easyqueryCore=e()}(self,(()=>(()=>{"use strict";var __webpack_modules__={412:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{e:()=>GoogleDataConverter});var _easydata_core__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(907),GoogleDataConverter=function(){function GoogleDataConverter(t){t||(t={cols:[],rows:[]}),"string"==typeof t?this.loadFromJSON(t):this.tableObj=t}return GoogleDataConverter.prototype.loadFromJSON=function(t){this.tableObj=JSON.parse(t)},GoogleDataConverter.prototype.toJSON=function(){return JSON.stringify(this.tableObj)},GoogleDataConverter.prototype.getObject=function(){return this.tableObj},GoogleDataConverter.prototype.isEmpty=function(){return 0==this.getNumberOfColumns()||0==this.getNumberOfRows()},GoogleDataConverter.prototype.getNumberOfColumns=function(){return this.tableObj.cols.length},GoogleDataConverter.prototype.getColumnObject=function(t){return t<this.tableObj.cols.length?this.tableObj.cols[t]:null},GoogleDataConverter.prototype.getColumnId=function(t){var e=this.getColumnObject(t);return e?e.id:null},GoogleDataConverter.prototype.getColumnLabel=function(t){var e=this.getColumnObject(t);return e?e.label:null},GoogleDataConverter.prototype.getColumnType=function(t){var e=this.getColumnObject(t);return e?e.type:null},GoogleDataConverter.prototype.getColumnProperties=function(t){var e=this.getColumnObject(t);return e?e.p:null},GoogleDataConverter.prototype.getNumberOfRows=function(){return this.tableObj.rows.length},GoogleDataConverter.prototype.convertValue=function(value,colIndex){var colType=this.googleDataTypeToDataType(this.getColumnType(colIndex));return[_easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Date,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.DateTime,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Time].includes(colType)?eval("new ".concat(value)):value},GoogleDataConverter.prototype.getValue=function(t,e){var r=t<this.tableObj.rows.length?this.tableObj.rows[t]:null;if(r){var o=e<this.tableObj.cols.length?r.c[e]:null;if(o)return this.convertValue(o.v,e)}return null},GoogleDataConverter.prototype.getRow=function(t){var e=this;return(t<this.tableObj.rows.length?this.tableObj.rows[t]:null).c.map((function(t,r){return e.convertValue(t.v,r)}),this)},GoogleDataConverter.prototype.convertTo=function(t){for(var e=this.getNumberOfColumns(),r=0;r<e;r++)t.columns.add({id:this.getColumnId(r),label:this.getColumnLabel(r),type:this.googleDataTypeToDataType(this.getColumnType(r))});var o=this.getNumberOfRows();for(r=0;r<o;r++)t.addRow(this.getRow(r))},GoogleDataConverter.prototype.googleDataTypeToDataType=function(t){switch(t){case"string":default:return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.String;case"number":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Float;case"boolean":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Bool;case"date":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Date;case"datetime":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.DateTime;case"timeofday":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Time}},GoogleDataConverter}()},907:(t,e,r)=>{var o,n;r.d(e,{$h:()=>T,g:()=>o,XH:()=>A,mb:()=>s,vp:()=>O,eN:()=>m,U4:()=>E,qR:()=>v,uF:()=>x,S$:()=>b,ag:()=>a,P6:()=>u}),function(t){t[t.Unknown=0]="Unknown",t[t.String=1]="String",t[t.Byte=2]="Byte",t[t.Word=3]="Word",t[t.Int32=4]="Int32",t[t.Int64=5]="Int64",t[t.Bool=6]="Bool",t[t.Float=7]="Float",t[t.Currency=8]="Currency",t[t.BCD=9]="BCD",t[t.Date=10]="Date",t[t.Time=11]="Time",t[t.DateTime=12]="DateTime",t[t.Autoinc=13]="Autoinc",t[t.Memo=14]="Memo",t[t.Blob=15]="Blob",t[t.FixedChar=16]="FixedChar",t[t.Guid=17]="Guid",t[t.Geometry=18]="Geometry",t[t.Geography=19]="Geography"}(o||(o={})),function(t){t[t.Data=0]="Data",t[t.Virtual=1]="Virtual",t[t.Lookup=2]="Lookup"}(n||(n={}));var i,s={Unknown:"Unknown",Edit:"EDIT",DateTime:"DATETIME",List:"LIST",CustomList:"CUSTOMLIST",File:"FILE"};!function(t){t.Trace="TRACE",t.Options="OPTIONS",t.Get="GET",t.Put="PUT",t.Post="POST",t.Delete="DELETE"}(i||(i={}));var a,u,l=function(){function t(t,e){this.xhr=t,this.method=e.method,this.url=e.url,this.headers=e.headers,this.queryParams=e.queryParams,this.data=e.data}return t.prototype.setHeader=function(t,e){this.headers[t]=e},t.prototype.setQueryParam=function(t,e){this.queryParams[t]=e},t.prototype.getXMLHttpRequest=function(){return this.xhr},t.prototype.getResponseHeaders=function(){if(this.xhr.readyState==this.xhr.HEADERS_RECEIVED){for(var t={},e=0,r=this.xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);e<r.length;e++){var o=r[e].split(": "),n=o.shift(),i=o.join(": ");t[n]=i}return t}return{}},t.prototype.open=function(){var t=this;if(this.xhr.readyState===this.xhr.UNSENT){var e=this.url;for(var r in this.queryParams&&Object.keys(this.queryParams).length>0&&(e+=encodeURI("?"+Object.keys(this.queryParams).map((function(e){return e+"="+t.queryParams[e]})).join("&"))),this.xhr.open(this.method,e,!0),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.headers)this.xhr.setRequestHeader(r,this.headers[r])}},t.prototype.abort=function(){this.xhr.abort()},t}();function c(t,e){for(var r="",o=0;o<e;o++)r+=t;return r}!function(t){var e,r={shortDateFormat:"MM/dd/yyyy",longDateFormat:"dd MMM, yyyy",editDateFormat:"MM/dd/yyyy",shortTimeFormat:"HH:mm",editTimeFormat:"HH:mm",longTimeFormat:"HH:mm:ss",shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],shortWeekDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longWeekDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],decimalSeparator:".",currency:"USD"},n={localeId:"en-US",englishName:"English",displayName:"English",texts:{ButtonOK:"OK",ButtonCancel:"Cancel",Yes:"Yes",No:"No",True:"True",False:"False"},settings:r},i={"en-US":n},s=[];function a(t){for(var e=0,r=s;e<r.length;e++){(0,r[e])(t)}}function l(){return e.localeId}function c(t){var r=i[t];r?u.assignDeep(e,r):(e.englishName=t,e.displayName=t,e.texts=u.assignDeep({},n.texts)),e.localeId=t}function d(){return e.settings}function h(t){e.settings||(e.settings=u.assignDeep({},r)),e.settings=u.assignDeep(e.settings,t)}function p(t,r){a(r);var o=e;t&&(r.localeId||(r.localeId=t),(o=i[t])||(o=u.assignDeep({},n),i[t]=o)),u.assignDeep(o,r)}function f(){var t,r,o,n,i,s,a="object"==typeof navigator?navigator.language:void 0;t=a,r=new Date(2020,5,7,19,34,56,88),o=r.toLocaleDateString(t,{year:"numeric",month:"numeric",day:"numeric"}),n=r.toLocaleTimeString(t,{hour:"numeric",minute:"numeric",second:"numeric"}),i=o.replace("07","dd").replace("7","d").replace("06","MM").replace("6","M").replace("2020","yyyy").replace("20","yy"),s=n.replace("19","HH").replace("07","hh").replace("7","h").replace("34","mm").replace("56","ss").replace("PM","tt"),e.settings||(e.settings={}),h({shortDateFormat:i,shortTimeFormat:s})}function g(t){var e,r=d();switch(t){case o.Date:e=r.shortDateFormat;break;case o.Time:e=r.shortTimeFormat;break;default:e=r.shortDateFormat+" "+r.shortTimeFormat}return e}function y(t){var e,r=d();switch(t){case o.Date:e=r.longDateFormat;break;case o.Time:e=r.longTimeFormat;break;default:e=r.longDateFormat+" "+r.longTimeFormat}return e}t.addMapper=function(t){s.push(t)},t.getLocales=function(){var t=[];for(var e in i)t.push({locale:e,englishName:i[e].englishName,displayName:i[e].displayName});return t.sort((function(t,e){return t.englishName>e.englishName?1:t.englishName===e.englishName?0:-1}))},t.getCurrentLocale=l,t.setLocale=function(t){console.warn("This method is deprecated. Use setCurrentLocale instead"),c(t)},t.setCurrentLocale=c,t.getText=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var o=e.texts,n="";if(t&&t.length)for(var i=t.length,s=0;s<i&&"object"==typeof(n=o[t[s]]);s++)o=n;return n},t.getLocaleSettings=d,t.getOneLocaleSetting=function(t){return e.settings[t]},t.getShortMonthName=function(t){var e=d();if(t>0&&t<13)return e.shortMonthNames[t-1];throw"Wrong month number: "+t},t.getLongMonthName=function(t){var e=d();if(t>0&&t<13)return e.longMonthNames[t-1];throw"Wrong month number: "+t},t.getShortWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.shortWeekDayNames.length>=t?e.shortWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.getLongWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.longWeekDayNames.length>=t?e.longWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.updateLocaleSettings=h,t.updateLocaleTexts=function(t){"object"==typeof t?(a({localeId:e.localeId,texts:t}),u.assignDeep(e.texts,t)):console.error("Wrong parameter type in updateLocaleTexts function call.The first parameter (localeId) is not necessary. Use updateLocaleTexts(texts) instead")},t.updateDefaultTexts=function(t){for(var r in i){var o=i[r];o.texts=u.assignDeep({},t,o.texts)}e.texts=u.assignDeep({},t,e.texts)},t.updateLocaleInfo=p,t.addLocale=function(t,e){p(t,e)},t.resetLocales=function(){e||(e=u.assignDeep({},n),f())},t.dateTimeToStr=function(t,e,r){return r?"d"==r?r=g(o.Date):"D"==r?r=y(o.Date):"f"==r?r=g(o.DateTime):"F"==r&&(r=y(o.DateTime)):r=g(e),u.dateTimeToStr(t,r)},t.numberToStr=function(e,r){if(r&&r.length>0){var o=r.charAt(0).toUpperCase();if("S"===o)return function(e,r){if(!m[r]){var o=r.split("|").filter((function(t){return t.length>0})).map((function(t){return t.split("=")}));if(m[r]={},o.length>0)if(o[0].length>1)for(var n=0,i=o;n<i.length;n++){var s=i[n];m[r][Number.parseInt(s[1])]=s[0]}else o.forEach((function(t,e){m[r][e]=t[0]}))}var a=m[r];if(void 0!==a[e]){s=a[e];return t.getText(s)||s}return e.toString()}(e,r.slice(1));if(["D","F","C"].indexOf(o)>=0){var n=l();return e.toLocaleString(n,function(t){var e=d(),r=t[0].toUpperCase(),o=t.length>1?Number.parseInt(t.slice(1)):"D"==r?1:2;switch(r){case"D":return{style:"decimal",useGrouping:!1,minimumIntegerDigits:o};case"C":return{style:"currency",currency:e.currency,minimumFractionDigits:o};default:return{style:"decimal",minimumFractionDigits:o,maximumFractionDigits:o}}}(r))}return function(t,e){for(var r=t.toString(),o="",n=r.length-1,i=e.length-1;i>=0;i--){var s=e.charAt(i);"#"===s||"0"===s?n>=0?(o+=r.charAt(n),n--):"0"===s&&(o+=0):o+=s}return o.split("").reverse().join("")}(Math.trunc(e),r)}var i=d();return u.numberToStr(e,i.decimalSeparator)},t.booleanToStr=function(e,r){if(r&&r.length>0&&"S"===r.charAt(0).toUpperCase()){var o=r.slice(1).split("|");if(o.length>1){var n=o[e?1:0];return t.getText(n)||n}}return"".concat(e)};var m={}}(a||(a={})),function(t){t.getAllDataTypes=function(){return Object.values(o).filter((function(t){return"number"==typeof t}))},t.getDateDataTypes=function(){return[o.Time,o.Date,o.DateTime]},t.getStringDataTypes=function(){return[o.String,o.Memo,o.FixedChar]};var e=[o.Byte,o.Word,o.Int32,o.Int64,o.Float,o.Currency,o.Autoinc];t.getNumericDataTypes=function(){return e};var r=[o.Byte,o.Word,o.Int32,o.Int64,o.Autoinc];function n(t,e,r){e||(e={});for(var o=0,s=r;o<s.length;o++){var a=s[o];if(a)for(var u in a)if(a.hasOwnProperty(u)){var l=a[u];null!==l&&"object"==typeof l?t.has(l)?e[u]=t.get(l):Array.isArray(l)?(e[u]=i(l),t.set(l,e[u])):(void 0!==e[u]&&null!=e[u]||(e[u]=Object.create(Object.getPrototypeOf(l))),t.set(l,e[u]),n(t,e[u],[l])):e[u]=l}}return e}function i(t){for(var e=[],r=0,o=t;r<o.length;r++){var n=o[r];e.push(n)}return e}t.assign=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var o=0;o<e.length;o++){var n=e[o];if(n)for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])}return t},t.assignDeep=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return n(new WeakMap,t,e)},t.getIfDefined=function(t,e){return void 0!==t?t:e},t.IsDefinedAndNotNull=function(t){return null!=t},t.copyArrayTo=function(t,e){for(var r=t.length,o=e.length,n=0;n<r&&n<o;n++)e[n]=t[n]},t.createArrayFrom=i,t.findItemById=function(t,e){for(var r=t.length,o=0;o<r;o++)if(t[o].id===e)return t[o];return null},t.findItemIndexById=function(t,e){for(var r=t.length,o=0;o<r;o++)if(t[o].id===e)return o;return-1},t.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=t.length,o=0;o<r;o++)if(e==t[o])return o;return-1},t.moveArrayItem=function(t,e,r){if(e>=t.length)throw"Index out of bounds: "+e;r>=t.length&&(r=t.length-1);var o=t.splice(e,1)[0];t.splice(r,0,o)},t.removeArrayItem=function(t,e){var r=t.indexOf(e);if(-1!=r)return t.splice(r,1)[0]},t.insertArrayItem=function(t,e,r){t.splice(e,0,r)},t.fillArray=function(t,e,r,o){void 0===r&&(r=0);for(var n=t.length>>>0,i=r>>0,s=i<0?Math.max(n+i,0):Math.min(i,n),a=void 0===o?n:o>>0,u=a<0?Math.max(n+a,0):Math.min(a,n);s<u;)t[s]=e,s++;return t},t.shiftToFitWindow=function(t,e){var r=document.getElementsByTagName("body")[0],o=window.innerWidth||document.documentElement.clientWidth||r.clientWidth,n=t+e,i=0;return n>o&&t+(i=o-n-10)<0&&(i=10-t),i},t.isObject=function(t){return null!==t&&("function"==typeof t||"object"==typeof t)},t.isNumericType=function(t){return e.indexOf(t)>=0},t.isIntType=function(t){return r.indexOf(t)>=0},t.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.areCompatibleDataTypes=function(t,e){return void 0===t||void 0===e||t==o.Unknown||e==o.Unknown||t==e||t==o.Date&&e==o.DateTime||t==o.DateTime&&e==o.Date},t.isPropSet=function(t,e){return t[e]||t[e.toLowerCase()]||t[e.toUpperCase()]};var s="0123456789abcdefghijklmnopqrstuvwxyz";function u(t,e){var r=t.length;if(r>e){var o=r/e,n="";n+=t[0];for(var i=o,s=void 0,a=1;a<r;a++)s=t[a],a+1>i&&(n+=s,i+=o);return n}return t}function l(t,e,r){return t.substr(0,e)+r+t.substr(e+r.length)}function d(t,e){return Math.floor(Math.random()*(e-t))+t}function h(t){var e=parseInt(t);if(isNaN(e))throw'"'.concat(t,'" is not a valid number');return e}t.generateId=function(t){t||(t="easy");var e=t.length>4?function(t,e){var r=t.split("-"),o=1,n=e;r.length<e&&(o=e/r.length,n=r.length);for(var i="",s=0;s<n;s++)i+=u(r[s],o);return i}(t,4):t;e&&e.length>0&&(e+="-");var r=c("",2),o=s.length-1;return r=l(r,0,s[d(0,o)]),e+(r=l(r,1,s[d(0,o)]))+function(t){var e=36,r=14,o=c("",r),n=t;do{o=l(o,r--,s[n%e]),n=Math.floor(n/=e)}while(n>0);return i=o.trim(),i.split("").reverse().join("");var i}(621355968e9+1e4*(new Date).getTime()-0x8d60e562e627800)},t.strToDateTime=function(t,e){if(!t||0==t.length)return new Date;var r=t.replace(/[^a-zA-Z0-9_]/g,"-"),o=e.replace(/[^a-zA-Z0-9_]/g,"-").split("-"),n=r.split("-"),i=o.indexOf("MM"),s=o.indexOf("dd"),a=o.indexOf("yyyy"),u=o.indexOf("HH"),l=o.indexOf("mm"),c=o.indexOf("ss"),d=new Date;try{var p=a>-1&&a<n.length?h(n[a]):d.getFullYear(),f=i>-1&&i<n.length?h(n[i])-1:d.getMonth()-1;if(f>11)throw"";var g=s>-1&&s<n.length?h(n[s]):d.getDate();if(g>function(t,e){return new Date(e,t+1,0).getDate()}(f,p))throw"";var y=u>-1&&u<n.length?h(n[u]):0;if(y>23)throw"";var m=l>-1&&l<n.length?h(n[l]):0;if(m>59)throw"";var v=c>-1&&c<n.length?h(n[c]):0;if(v>59)throw"";return new Date(p,f,g,y,m,v)}catch(e){throw"".concat(t," is not a valid date.")}},t.strToTime=function(t){var e=t.split(":");try{var r=e.length>0?h(e[0]):0;if(r>23)throw"";var o=e.length>1?h(e[1]):0;if(o>59)throw"";var n=e.length>1?h(e[1]):0;if(n>59)throw"";return new Date(0,0,0,r,o,n)}catch(e){throw"".concat(t," is not a valid time.")}};var p=/\[([^\]]+)]|y{2,4}|M{1,4}|d{1,2}|H{1,2}|h{1,2}|m{2}|s{2}|t{2}/g;t.dateTimeToStr=function(t,e){var r=t.getFullYear().toString(),o=t.getMonth()+1,n=t.getDate(),i=t.getHours(),s=t.getMinutes(),u=t.getSeconds(),l=i%12||12,c=i>11,d={yyyy:r,yy:r.substring(r.length-2),MMMM:a.getLongMonthName(o),MMM:a.getShortMonthName(o),MM:o<10?"0"+o:o.toString(),M:o.toString(),dd:n<10?"0"+n:n.toString(),d:n.toString(),HH:i<10?"0"+i:i.toString(),H:i.toString(),hh:l<10?"0"+l:l.toString(),h:l.toString(),tt:c?"PM":"AM",mm:s<10?"0"+s:s.toString(),ss:u<10?"0"+u:u.toString()};return e.replace(p,(function(t,e){return e||d[t]}))},t.numberToStr=function(t,e){return e=e||a.getLocaleSettings().decimalSeparator,t.toString().replace(".",e)}}(u||(u={}));var d,h,p=function(){function t(t,e){this.request=t,this.promise=e}return t.prototype.getPromise=function(){return this.promise},t.prototype.getRequest=function(){return this.request},t.prototype.then=function(t,e){return this.promise.then(t,e)},t.prototype.catch=function(t){return this.promise.catch(t)},t.prototype.finally=function(t){return this.promise.finally(t)},t}(),f=(d=function(t,e){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},d(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),g=function(){return g=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},g.apply(this,arguments)},y=function(t){function e(e,r){var o=t.call(this,r)||this;return o.status=e,o}return f(e,t),e}(Error),m=function(){function t(){this.defaultHeaders={},this.customPayload=void 0}return Object.defineProperty(t.prototype,"responseBody",{get:function(){return this._responseBody},enumerable:!1,configurable:!0}),t.prototype.get=function(t,e){return this.send(i.Get,t,null,e)},t.prototype.post=function(t,e,r){return this.send(i.Post,t,e,r)},t.prototype.put=function(t,e,r){return this.send(i.Put,t,e,r)},t.prototype.delete=function(t,e,r){return this.send(i.Delete,t,e,r)},t.prototype.send=function(e,r,o,n){var i=this,s=(n=n||{}).dataType||"json",a=n.contentType||"form-data"!==s?"application/json":null;o&&"form-data"!=s&&this.customPayload&&(o.data=u.assignDeep(o.data||{},this.customPayload));var c=new("onload"in new XMLHttpRequest?XMLHttpRequest:window.XDomainRequest),d={method:e,url:r,headers:g(g({},this.defaultHeaders),n.headers||{}),queryParams:n.queryParams||{},data:o};a&&(d.headers["Content-Type"]=a);var h=new l(c,d);this.beforeEachRequest&&(console.warn("HttpClient: 'beforeEachRequest' is deprecated and will be removed in future updates.\n Use 'onRequest' instead"),this.beforeEachRequest(h)),this.onRequest&&this.onRequest(h);var f=h.data&&"string"!=typeof h.data&&"json"==s?JSON.stringify(h.data):h.data;return h.open(),new p(h,new Promise((function(e,o){n.responseType&&(c.responseType=n.responseType),c.onerror=function(t){o(new y(c.status,c.responseText))},c.onreadystatechange=function(){if(4==c.readyState){var n=c.getResponseHeader("Content-Type")||"",s=c.status;if(0===s)o(new y(s,"Network error or the request was aborted"));else if(s>=200&&s<400){var a="arraybuffer"===c.responseType||"blob"===c.responseType?c.response:0==n.indexOf("application/json")?JSON.parse(c.responseText):c.responseText;i._responseBody=a,i.onResponse&&i.onResponse(c),e(a)}else{("arraybuffer"===c.responseType||"blob"===c.responseType?t.decodeArrayBuffer(c.response):Promise.resolve(c.responseText)).then((function(t){var e=0==n.indexOf("application/json")?JSON.parse(t):t;i._responseBody=e;var a=e.message||(404==s?"No such endpoint: ".concat(r):e);o(new y(s,a))}))}}},c.send(f)})))},t.decodeArrayBuffer=function(t){var e=new FileReader;return new Promise((function(r){e.onloadend=function(){e.readyState==FileReader.DONE&&r(e.result)},e.readAsText(new Blob([t]))}))},t}(),v=function(){function t(t){this.isEditable=!0,this.name="",this.caption="",this.description="",this.parent=t,this.attributes=new Array,this.subEntities=new Array}return t.prototype.loadFromData=function(t,e){if(e){if(this.id=e.id,this.name=e.name,this.captionPlural=e.namePlur,this.caption=e.name,this.description=e.desc,void 0!==e.ied&&(this.isEditable=e.ied),this.subEntities=new Array,e.ents)for(var r=0;r<e.ents.length;r++){var o=t.createEntity(this);o.loadFromData(t,e.ents[r]),this.subEntities.push(o)}if(this.attributes=new Array,e.attrs)for(r=0;r<e.attrs.length;r++){var n=t.createEntityAttr(this);n.loadFromData(t,e.attrs[r]),this.attributes.push(n)}}},t.prototype.scan=function(t,e){var r={stop:!1},o=function(n){if(e&&e(n,r),n.attributes)for(var i=n.attributes.length,s=0;s<i&&!r.stop;s++){var a=n.attributes[s];if(t&&t(a,r),r.stop)return}if(n.subEntities){var u=n.subEntities.length;for(s=0;s<u&&!r.stop;s++)o(n.subEntities[s])}};o(this)},t.prototype.getFirstPrimaryAttr=function(){return this.getPrimaryAttrs()[0]},t.prototype.getPrimaryAttrs=function(){return this.attributes.filter((function(t){return t.isPrimaryKey}))},t}(),x=function(){function t(t){this.id="",this.caption="{Unrecognized attribute}",this.dataType=o.String,this.size=0,this.isPrimaryKey=!1,this.isForeignKey=!1,this.isNullable=!0,this.showOnView=!0,this.isEditable=!0,this.showOnCreate=!0,this.showOnEdit=!0,this.showInLookup=!1,this.lookupAttr="",this.expr="",this.entity=t,this.kind=n.Data}return t.prototype.loadFromData=function(t,e){if(e){this.id=e.id,this.description=e.desc,this.caption=e.cptn,this.dataType=e.dtype,this.isPrimaryKey=e.ipk,this.isForeignKey=e.ifk,this.size=e.size,this.lookupAttr=e.lattr,this.lookupEntity=e.lent,this.dataAttr=e.dattr,this.lookupDataAttr=e.ldattr;var r=u.getDateDataTypes().indexOf(this.dataType);this.defaultValue=e.defVal&&r?new Date(e.defVal):e.defVal,this.isNullable=u.getIfDefined(e.nul,this.isNullable),this.isEditable=u.getIfDefined(e.ied,this.isEditable),this.showOnView=u.getIfDefined(e.ivis||e.sov,this.showOnView),this.showOnCreate=u.getIfDefined(e.soc,this.showOnCreate),this.showOnEdit=u.getIfDefined(e.soe,this.showOnEdit),this.showInLookup=u.getIfDefined(e.sil,this.showInLookup),this.kind=e.kind,this.displayFormat=e.dfmt,e.udata&&(this.userData=e.udata),e.edtr&&(this.defaultEditor=t.getEditorById(e.edtr)||t.createValueEditor())}},t}(),b=function(){function t(){this.id="",this.tag=s.Unknown,this.resType=o.Unknown,this.defValue=""}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.tag=t.tag,this.defValue=t.defval,this.resType=t.rtype,this.accept=t.accept,this.multiline=t.multiline,t.subType&&(this.resType=t.subType),t.name&&(this.name=t.name),t.values&&(this.values=t.values))},t.prototype.getValueText=function(t){var e="";if(!this.values)return e;if(Array.isArray(t))for(var r=0,o=this.values;r<o.length;r++){var n=o[r];t.indexOf(n.id)>=0&&(e+=n.text+",")}else for(var i=0,s=this.values;i<s.length;i++){(n=s[i]).id===t&&(e+=n.text+",")}return e&&(e=e.substring(0,e.length-1)),e},t}(),E=function(){function t(){this.mainEntity=null,this.id="__none",this.name="Empty model",this.rootEntity=this.createEntity(),this.displayFormats=new Map}return t.prototype.getMainEntity=function(){return this.mainEntity},t.prototype.createEntity=function(t){return new v(t)},t.prototype.createEntityAttr=function(t){return new x(t)},t.prototype.createValueEditor=function(){return new b},t.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},t.prototype.loadFromData=function(t){if(this.id=t.id,this.name=t.name,this.version=t.vers,this.editors=new Array,t.editors)for(var e=0;e<t.editors.length;e++){var r=this.createValueEditor();r.loadFromData(t.editors[e]),this.editors.push(r)}if(this.rootEntity.loadFromData(this,t.entroot),this.displayFormats=new Map,t.displayFormats)for(var n in t.displayFormats){var i=o[n],s=t.displayFormats[n]||new Array;this.displayFormats.set(i,s)}},t.prototype.getDisplayFormats=function(){return this.displayFormats},t.prototype.getDisplayFormatsForType=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t):[]},t.prototype.getDefaultFormat=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t).filter((function(t){return t.isdef}))[0]:null},t.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},t.prototype.isEmpty=function(){return 0===this.rootEntity.subEntities.length&&0===this.rootEntity.attributes.length},t.prototype.getId=function(){return this.id},t.prototype.getName=function(){return this.name},t.prototype.getRootEntity=function(){return this.rootEntity},t.prototype.getEditorById=function(t){for(var e=0,r=this.editors;e<r.length;e++){var o=r[e];if(o.id===t)return o}return null},t.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||null},t.prototype.checkAttrProperty=function(t,e){var r=this.getAttributeById(t);if(r){if(void 0===r[e])throw"No such property: "+e;return!!r[e]||!!r.lookupAttr&&(t=r.lookupAttr,(r=this.getAttributeById(t))&&r[e])}return!1},t.prototype.getEntityAttrById=function(t,e){var r,o;if(t.attributes){var n=t.attributes.length;for(r=0;r<n;r++)if(t.attributes[r].id==e)return t.attributes[r]}if(t.subEntities){var i=t.subEntities.length;for(r=0;r<i;r++)if(o=this.getEntityAttrById(t.subEntities[r],e))return o}return null},t.prototype.listByEntityWithFilter=function(t,e){var r,o=new Array,n=null;if(t.subEntities)for(var i=t.subEntities.length,s=0;s<i;s++){if(n=t.subEntities[s],!e||e(n,null))(r=a.getText("Entities",n.name))||(r=n.caption),(h=u.assign(this.createEntity(),{id:n.name,text:r,items:[],isEntity:!0})).items=this.listByEntityWithFilter(n,e),h.items.length>0&&o.push(h)}var l=null;if(t.attributes)for(var c=t.attributes.length,d=0;d<c;d++)if(l=t.attributes[d],!e||e(t,l)){(r=a.getText("Attributes",l.id))||(r=l.caption);var h=u.assign(this.createEntity(),{id:l.id,text:r,dataType:l.dataType});o.push(h)}return o},t.prototype.listByEntity=function(t,e,r){e=e||{};var o,n=[],i=[],s=null;if(t.subEntities)for(var l=t.subEntities.length,c=0;c<l;c++)if(s=t.subEntities[c],!r||r(s,null)){o=a.getText("Entities",s.name)||s.caption;var d=u.assign(this.createEntity(),{id:s.name,text:o,items:[],isEntity:!0,description:s.description}),h=u.assign({},e);h.includeRootData=!1,d.items=this.listByEntity(s,h,r),d.items.length>0&&n.push(d)}var p=null;if(t.attributes)for(var f=t.attributes.length,g=0;g<f;g++)p=t.attributes[g],r&&!r(t,p)||(o=a.getText("Attributes",p.id)||p.caption,i.push(u.assign(this.createEntityAttr(t),{id:p.id,text:o,dataType:p.dataType,lookupAttr:p.lookupAttr,description:p.description})));var y,m=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(n.sort(m),i.sort(m)),y=e.attrPlacement&&0!=e.attrPlacement?i.concat(n):n.concat(i),2==e.attrPlacement&&y.sort(m),e.includeRootData?((o=a.getText("Entities",t.name))||(o=t.caption),{id:t.name,text:o,items:y}):y},t.prototype.clear=function(){this.rootEntity=this.createEntity(),this.editors=[],this.version=""},t.prototype.addDefaultValueEditors=function(){this.addOrUpdateValueEditor("_DTE",s.Edit,o.String).defValue="",this.addOrUpdateValueEditor("_DPDE",s.DateTime,o.DateTime),this.addOrUpdateValueEditor("_DPTE",s.DateTime,o.DateTime)},t.prototype.addOrUpdateValueEditor=function(t,e,r){var o=u.findItemById(this.editors,t);return o||((o=this.createValueEditor()).id=t,this.editors.push(o)),o.tag=e,o.resType=r,o},t.prototype.getEntitiesTree=function(t,e){return this.listByEntity(this.getRootEntity(),t,e)},t.prototype.getEntitiesTreeWithFilter=function(t){return this.listByEntityWithFilter(this.getRootEntity(),t)},t.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},t.prototype.getEntityPathByAttr=function(t,e,r,o){if(!t)return"";r=r||" ";var n="";if(t.caption&&!o){var i=a.getText("Entities",t.caption);n=i||t.caption}if(t.attributes)for(var s=t.attributes.length,u=0;u<s;u++)if(t.attributes[u].id==e)return n;if(t.subEntities){var l=t.subEntities.length;for(u=0;u<l;u++){var c=t.subEntities[u],d=this.getEntityPathByAttr(c,e,r,!1);if(""!==d)return""!==n&&(d=n+r+d),d}}return""},t.prototype.getAttributeText=function(t,e){var r=a.getText("Attributes",t.id);if(r||(r=t.caption),!e)return r;var o=this.getFullEntityPathByAttr(t.id," ");return(o?e.replace(new RegExp("{attr}","g"),r).replace(new RegExp("{entity}","g"),o):r).trim()},t.prototype.runThroughEntities=function(t,e){this.getRootEntity().scan(t,e)},t.prototype.getFirstAttributeByFilter=function(t){var e=null;return this.runThroughEntities((function(r,o){t(r)&&(o.stop=!0,e=r)}),null),e},t}(),C=function(){return C=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},C.apply(this,arguments)},T=function(){function t(t){this.colStore=t,this.aggregates=[],this.groups=[],this.useGrandTotals=!1,this.useRecordCount=!1,this._caseSensitiveGroups=!1,this.COUNT_FIELD_NAME="GRPRECCNT"}return Object.defineProperty(t.prototype,"caseSensitiveGroups",{get:function(){return this._caseSensitiveGroups},set:function(t){this._caseSensitiveGroups=t,this.updateCompareProc()},enumerable:!1,configurable:!0}),t.prototype.updateCompareProc=function(){this.compareValues=this._caseSensitiveGroups?this.strictCompare:this.caseInsensitiveCompare},t.prototype.addGroup=function(t){var e=t.columns||this.colStore.getColumnIds(t.from,t.to);if(!this.colStore.validateColumns(e))throw"Invalid columns: "+e;if(this.hasColumnsInUse(e))throw"Can't add same columns to different groups/aggregates";return this.groups.push(C({columns:e},t)),this},t.prototype.addAggregateColumn=function(t,e){var r="string"==typeof t?t:this.colStore.getColumnIds(t,t)[0];if(this.hasColumnsInUse([r])||!this.colStore.validateAggregate(r,e))throw"Invalid aggregation function for the column: "+r;return this.aggregates.push({colId:r,funcId:e}),this},t.prototype.addGrandTotals=function(){return this.useGrandTotals=!0,this},t.prototype.addCounts=function(){return this.useRecordCount=!0,this},t.prototype.getGroups=function(){var t=this,e=[];return this.groups.map((function(r){return e=e.concat(r.columns),C(C({},r),{columns:Array.from(e),aggregates:Array.from(t.aggregates)})}))},t.prototype.getInternalGroups=function(){return this.groups},t.prototype.lastGroup=function(){var t=this.getGroups();return t[t.length-1]},t.prototype.getAggregates=function(){return this.aggregates},t.prototype.hasAggregates=function(){return this.aggregates.length>0},t.prototype.hasGroups=function(){return this.groups.length>0},t.prototype.hasGrandTotals=function(){return this.useGrandTotals},t.prototype.hasRecordCount=function(){return this.useRecordCount},t.prototype.isEmpty=function(){return!(this.hasAggregates()||this.hasGroups()||this.hasAggregates()||this.hasRecordCount())},t.prototype.drop=function(){console.warn('"drop()" method is obsolete. Use "clear()" instead'),this.clear()},t.prototype.clear=function(){return this.groups=[],this.aggregates=[],this.useGrandTotals=!1,this.useRecordCount=!1,this.caseSensitiveGroups=!1,this},t.prototype.hasColumnsInUse=function(t){for(var e=0,r=this.groups;e<r.length;e++){if(r[e].columns.filter((function(e){return t.indexOf(e)>=0})).length>0)return!0}for(var o=0,n=this.aggregates;o<n.length;o++){var i=n[o];if(t.indexOf(i.colId)>=0)return!0}return!1},t.prototype.needAggrCalculation=function(){return(this.hasAggregates()||this.hasRecordCount())&&(this.hasGrandTotals()||this.hasGroups())},t.prototype.saveToData=function(){return{groups:Array.from(this.groups),ugt:this.useGrandTotals,urc:this.useRecordCount,csg:this.caseSensitiveGroups,aggregates:Array.from(this.aggregates)}},t.prototype.loadFromData=function(t){t&&(void 0!==t.ugt&&(this.useGrandTotals=t.ugt),void 0!==t.urc&&(this.useRecordCount=t.urc),void 0!==t.csg&&(this.caseSensitiveGroups=t.csg),t.groups&&(this.groups=Array.from(t.groups)),t.aggregates&&(this.aggregates=Array.from(t.aggregates)))},t.prototype.buildGroupKey=function(t,e){var r=!this.caseSensitiveGroups,o={};if(t)for(var n=0,i=t.columns;n<i.length;n++){var s=i[n],a=e.getValue(s);r&&"string"==typeof a&&(a=a.toLowerCase()),o[s]=a}return o},t.prototype.strictCompare=function(t,e){return t instanceof Date?t.getTime()===e.getTime():t===e},t.prototype.caseInsensitiveCompare=function(t,e){return t instanceof Date?t.getTime()===e.getTime():("string"==typeof t?t.toLowerCase():t)===("string"==typeof e?e.toLowerCase():e)},t}();!function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Center=2]="Center",t[t.Right=3]="Right"}(h||(h={}));var w,I=function(t){if(!t)throw Error("Options are required");if(!t.id)throw Error("Field Id is required");if(!t.label)throw Error("Label is required");this.id=t.id,this.type=u.getIfDefined(t.type,o.String),this.label=t.label,this.originAttrId=t.originAttrId,this.isAggr=t.isAggr||!1,this.displayFormat=t.dfmt,this.groupFooterColumnTemplate=t.gfct,this.style=t.style||{},this.description=t.description,this.calculatedWidth=0},D=function(){function t(){this.items=[],this.mapper={},this._dateColumnIdx=[]}return Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!1,configurable:!0}),t.prototype.add=function(t){var e;e=t instanceof I?t:new I(t);var r=this.items.length;return this.items.push(e),this.mapper[e.id]=r,[o.Date,o.DateTime,o.Time].indexOf(e.type)>=0&&this._dateColumnIdx.push(r),r},t.prototype.updateDateColumnIdx=function(){this._dateColumnIdx=this.getItems().filter((function(t){return[o.Date,o.DateTime,o.Time].indexOf(t.type)>=0})).map((function(t,e){return e}))},t.prototype.put=function(t,e){t>=0&&t<this.count&&(this.items[t]=e,this.updateDateColumnIdx())},t.prototype.move=function(t,e){var r=this.items.indexOf(t);r>=0&&r!=e&&(u.moveArrayItem(this.items,r,e),this.updateDateColumnIdx())},t.prototype.get=function(t){return t>=0&&t<this.count?this.items[t]:null},t.prototype.getIndex=function(t){return this.mapper[t]},t.prototype.getItems=function(){return this.items},t.prototype.getDateColumnIndexes=function(){return this._dateColumnIdx},t.prototype.removeAt=function(t){var e=this.get(t);this.items.splice(t,1);var r=this._dateColumnIdx.indexOf(t);r>=0&&this._dateColumnIdx.splice(r,1),delete this.mapper[e.id]},t.prototype.clear=function(){this.items=[],this._dateColumnIdx=[],this.mapper={}},t}(),S=function(){function t(t,e){this.columns=t,this.values=e}return t.prototype.toArray=function(){return Array.from(this.values)},t.prototype.size=function(){return this.values.length},t.prototype.getValue=function(t){var e;if("string"==typeof t){if(void 0===(e=this.columns.getIndex(t)))throw new RangeError("No column with id '".concat(t,"'"))}else e=t;if(e>=this.values.length)throw new RangeError("Out of range: "+e);return this.values[e]},t.prototype.setValue=function(t,e){var r;if("string"==typeof t){if(void 0===(r=this.columns.getIndex(t)))throw new RangeError("No column with id '".concat(t,"'"))}else r=t;if(r>=this.values.length)throw new RangeError("Out of range: "+r);this.values[r]=e},t}(),A=function(){function t(t){if(this._chunkSize=1e3,this._elasticChunks=!1,this.cachedRows=[],this.total=0,this.loader=null,this.needTotal=!0,this.isInMemory=!1,t=t||{},this._chunkSize=t.chunkSize||this._chunkSize,this._elasticChunks=t.elasticChunks||this._elasticChunks,this.loader=t.loader,void 0!==t.inMemory&&(this.isInMemory=t.inMemory),this.isInMemory&&(this.needTotal=!1),this._columns=new D,this.onUpdate=t.onUpdate,t.columns)for(var e=0,r=t.columns;e<r.length;e++){var o=r[e];this._columns.add(o)}if(t.rows)for(var n=0,i=t.rows;n<i.length;n++){var s=i[n],a=this.createRow(s);this.addRow(a)}this.needTotal=!this._elasticChunks}return Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chunkSize",{get:function(){return this._chunkSize},set:function(t){this._chunkSize=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"elasticChunks",{get:function(){return this._elasticChunks},set:function(t){this._elasticChunks=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!1,configurable:!0}),t.prototype.getRows=function(t){var e=this,r=0,o=this._chunkSize;t&&("page"in t?(r=t.pageSize*(t.page-1),o=t.pageSize):(r=t.offset,o=t.limit));var n=r+o;if(!this.needTotal&&!this.elasticChunks){if(r>=this.total)return Promise.resolve([]);n>this.total&&(n=this.total)}if(this.isInMemory&&n>this.cachedRows.length&&(n=this.cachedRows.length),n<=this.cachedRows.length)return Promise.resolve(this.cachedRows.slice(r,n));if(!this.loader)throw"Loader is not defined. Can't get the rows from ".concat(r," to ").concat(n);var i=this.needTotal;this.needTotal&&(this.needTotal=!1);var s=this.cachedRows.length,a=n-s;return a<this._chunkSize&&(a=this._chunkSize),this.loader.loadChunk({offset:s,limit:a,needTotal:i}).then((function(t){(i&&(e.total=t.total),Array.prototype.push.apply(e.cachedRows,t.table.getCachedRows()),n>e.cachedRows.length&&(n=e.cachedRows.length),e.elasticChunks)&&(t.table.getCachedCount()<a&&(e.total=e.cachedRows.length));return e.fireUpdated(),e.cachedRows.slice(r,n)}))},t.prototype.getRow=function(t){return this.getRows({offset:t,limit:1}).then((function(t){return t.length>0?t[0]:null}))},t.prototype.getTotal=function(){return this.total},t.prototype.setTotal=function(t){this.total=t,this.needTotal=!1},t.prototype.getCachedCount=function(){return this.cachedRows.length},t.prototype.clear=function(){this.columns.clear(),this.cachedRows=[],this.total=0,this.needTotal=!this._elasticChunks,this.fireUpdated()},t.prototype.createRow=function(t){var e=this,r=this._columns.getDateColumnIndexes(),o=new Array(this._columns.count),n=t instanceof S?function(e){return t.getValue(e)}:function(e){return t[e]};return t&&this.columns.getItems().forEach((function(t){var i=n(t.id),s=e.columns.getIndex(t.id);o[s]=r.indexOf(s)>=0?e.mapDate(i,t.type):i})),new S(this._columns,o)},t.prototype.mapDate=function(t,e){if(t){var r=new Date(t);return isNaN(r.getTime())&&e==o.Time&&(r=u.strToTime(t)),r}return null},t.prototype.addRow=function(t){var e;if(Array.isArray(t)){var r=t,o=this._columns.getDateColumnIndexes();if(o.length>0)for(var n=0,i=o;n<i.length;n++){var s=i[n];r[s]&&(r[s]=this.mapDate(r[s],this._columns.get(s).type))}e=new S(this._columns,r)}else e=this.createRow(t);this.cachedRows.push(e);var a=this.getCachedCount();return a>this.total&&(this.total=a),e},t.prototype.getCachedRows=function(){return this.cachedRows},t.prototype.totalIsKnown=function(){return this.elasticChunks?this.getCachedCount()===this.total:!this.needTotal},t.prototype.fireUpdated=function(){this.onUpdate&&this.onUpdate(this)},t}(),_=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},t}(),O=function(){function t(t){this.silentMode=0,this.events=new Array,this.source=t}return t.prototype.subscribe=function(t,e){var r=this.getEventRecByType(t),o={id:_.newGuid(),callback:e};return r?r.eventCallbacks.push(o):(r={type:t,eventCallbacks:new Array(o)},this.events.push(r)),o.id},t.prototype.unsubscribe=function(t,e){var r=this.getEventRecByType(t);if(r){var o=-1;for(o=0;o<r.eventCallbacks.length&&r.eventCallbacks[o].id!==e;o++);o>=0&&r.eventCallbacks.splice(o,1)}},t.prototype.fire=function(t,e,r,o){if(void 0===r&&(r=0),void 0===o&&(o=!1),!this.silentMode||o){var n=this.getEventRecByType(t);if(n){var i={type:t,source:this.source,data:e},s=function(){for(var t=0,e=n.eventCallbacks;t<e.length;t++){e[t].callback(i)}};r>0?setTimeout(s,r):s()}}},t.prototype.enterSilentMode=function(){this.silentMode++},t.prototype.exitSilentMode=function(){this.silentMode&&this.silentMode--},t.prototype.isSilent=function(){return this.silentMode>0},t.prototype.getEventRecByType=function(t){for(var e=0,r=this.events;e<r.length;e++){var o=r[e];if(o.type==t)return o}return null},t}();!function(t){t.renderLiquidTemplate=function(t,e){var r=t;if(e)for(var o in e){var n=new RegExp("{{"+o+"}}","g");r=r.replace(n,e[o])}return r}}(w||(w={})),a.resetLocales(),"function"!=typeof Object.values&&(Object.values=function(t){return Object.keys(t).map((function(e){return t[e]}))}),"function"!=typeof Math.trunc&&(Math.trunc=function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)})}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=(t,e)=>{for(var r in e)__webpack_require__.o(e,r)&&!__webpack_require__.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{AggrFunction:()=>u,BrowserQueryStorage:()=>P,CondTag:()=>D,Condition:()=>F,ConditionPart:()=>S,DataKind:()=>s,DataModel:()=>w,DefaultAggregatesCalculator:()=>V,EasyQueryDataLoader:()=>H,EmptyChunk:()=>a,Entity:()=>g,EntityAttr:()=>y,EqAction:()=>O,EqActionResult:()=>z,EqAggregatesContainer:()=>U,EqContext:()=>X,EqEditorTag:()=>v,EqModelLoader:()=>L,EqQueryFileLoader:()=>G,EqServerDataFetcher:()=>Q,EqServerExporter:()=>Y,EqServerModelLoader:()=>N,EqServerQuerySynchronizer:()=>B,EqServerValueListResolver:()=>j,EqServiceProvider:()=>W,EqValueEditor:()=>c,ExprTag:()=>d,Expression:()=>I,FormatParser:()=>n,GoogleDataConverter:()=>J.e,InMemoryModelStorage:()=>K,InvalidQueryError:()=>M,LinkType:()=>t,Operand:()=>p,Operator:()=>h,Query:()=>k,QueryChangeAction:()=>b,QueryChangePart:()=>x,QueryColumn:()=>A,SortDirection:()=>E,Tree:()=>C,Widget:()=>Z,WidgetGroup:()=>_,eqconsts:()=>r,equtils:()=>e,i18n:()=>o.ag,versionInfo:()=>tt});var t,e,r,o=__webpack_require__(907),n=function(){function t(t){this.start(t)}return t.prototype.start=function(t){this.formatStr=t,this.pos=0,this.exprNum=0,this.tokenText=""},t.prototype.skipSpaces=function(){for(;this.pos<this.formatStr.length&&" "===this.formatStr.charAt(this.pos);)this.pos++},t.prototype.next=function(){if(this.skipSpaces(),this.pos>=this.formatStr.length)return!1;var t=0;if("{"===this.formatStr.charAt(this.pos)){if((t=this.formatStr.indexOf("}",this.pos))<0)return!1;this.tokenText=this.formatStr.substring(this.pos,t+1),0===this.tokenText.indexOf("{expr")&&(this.token="expression",this.exprNum=parseInt(this.tokenText.substring(5,this.tokenText.length))),this.pos=t+1}else if("["===this.formatStr.charAt(this.pos)&&this.pos<this.formatStr.length-1&&"["===this.formatStr.charAt(this.pos+1))this.pos+=2,t=this.formatStr.indexOf("]]",this.pos),this.token="operator",this.tokenText=this.formatStr.substring(this.pos,t),this.pos=t+2;else{this.token="text";var e=this.formatStr.indexOf("{",this.pos);e<0&&(e=this.formatStr.length);var r=this.formatStr.indexOf("[[",this.pos);r<0&&(r=this.formatStr.length),t=Math.min(e,r),this.tokenText=this.formatStr.substring(this.pos,t).trim(),this.pos=t}return!0},t.prototype.getToken=function(){return{type:this.token,text:this.tokenText,index:this.exprNum-1}},t.prototype.parse=function(){for(var t=[];this.next();)t.push(this.getToken());return t},t}();!function(t){t[t.None=0]="None",t[t.Any=1]="Any",t[t.NotAll=2]="NotAll",t[t.All=3]="All"}(t||(t={})),function(e){e.combinePath=function(t,e){var r=t;return null!=r&&r.length>0?("/"!=r.charAt(r.length-1)&&(r+="/"),r+=e):r=e,r},e.strToLinkType=function(e){return"All"==e?t.All:"NotAll"==e?t.NotAll:"Any"==e?t.Any:t.None},e.linkTypeToStr=function(e){return e===t.All?"All":e===t.NotAll?"NotAll":e==t.Any?"Any":"None"},e.parseOperatorFormat=function(t){var e=o.ag.getText("Operators",t.id,"format");return e||(e=o.ag.getText("Operators",t.id,"displayFormat")),e||(e=t.displayFormat),new n(e).parse()},e.convertValue=function(t,e,r){switch(r){case o.g.String:return t;case o.g.Autoinc,o.g.Byte,o.g.Int32,o.g.Int64,o.g.Word:var n=parseInt(t);return isNaN(n)?"":n.toString();case o.g.Currency,o.g.Float:var i=parseFloat(t);return isNaN(i)?"":i.toString();default:return""}}}(e||(e={})),function(t){var e=function(){this.SpecDateValues=[{id:"${Today}",key:"Today",isDefault:!0},{id:"${Yesterday}",key:"Yesterday"},{id:"${Tomorrow}",key:"Tomorrow"},{id:"${FirstDayOfMonth}",key:"FirstDayOfMonth"},{id:"${FirstDayOfYear}",key:"FirstDayOfYear"}],this.SpecTimeValues=[{id:"${Now}",key:"Now",isDefault:!0},{id:"${HourStart}",key:"HourStart"},{id:"${Midnight}",key:"Midnight"},{id:"${Noon}",key:"Noon"}],this.BooleanValues=[{id:"${false}",key:"False"},{id:"${true}",key:"True",isDefault:!0}]};t.constLists=new e,t.predicateLinkTypeList=[{id:"All",key:"LinkTypeAll"},{id:"Any",key:"LinkTypeAny"},{id:"None",key:"LinkTypeNone"},{id:"NotAll",key:"LinkTypeNotAll"}]}(r||(r={}));var i,s,a={offset:0,limit:0,needTotal:!1},u=function(){function t(){this.id="",this.caption="",this.sqlExpr="",this.displayFormat="",this.appliedTypes=[]}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.caption=t.cptn,this.displayFormat=t.fmt,this.sqlExpr=t.expr,this.appliedTypes=t.dtypes||this.appliedTypes)},t.prototype.getAppliedTypesOrDefault=function(){return this.appliedTypes.length>0?this.appliedTypes:"SUM"===this.id||"AVG"===this.id?[o.g.Autoinc,o.g.Byte,o.g.Currency,o.g.Float,o.g.Int32,o.g.Int64,o.g.Word]:"MIN"===this.id||"MAX"===this.id?[o.g.Autoinc,o.g.BCD,o.g.Byte,o.g.Currency,o.g.Date,o.g.DateTime,o.g.Time,o.g.Float,o.g.Int32,o.g.Int64,o.g.Word]:o.P6.getAllDataTypes()},t}(),l=(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),c=function(t){function e(){return t.call(this)||this}return l(e,t),e.prototype.loadFromData=function(e){t.prototype.loadFromData.call(this,e),e&&(e.sql&&(this.statement=e.sql),e.extraParams&&(this.extraParams=e.extraParams))},e}(o.S$);!function(t){t[t.Scalar=0]="Scalar",t[t.Const=1]="Const",t[t.Attribute=2]="Attribute",t[t.List=4]="List",t[t.Query=5]="Query",t[t.ParentColumn=6]="ParentColumn"}(s||(s={}));var d,h=function(){function t(){this.id="",this.expr="",this.constValueFormat="{const}",this.caption="{Unrecognized operator}",this.displayFormat="{expr1} [[{unrecognized operator}]] {expr2}",this.isRange=!1,this.caseIns=!1,this.paramCount=2,this.defaultOperand=new p,this.appliedTypes=[],this.operands=new Array}return t.prototype.loadFromData=function(t,e){if(e&&(this.id=e.id,this.caption=e.cptn,this.caseIns=e.caseIns,this.isRange=e.isRange,this.displayFormat=e.fmt,this.paramCount=e.pcnt,this.expr=e.expr,this.appliedTypes=e.dtypes||this.appliedTypes,e.defOperand&&this.defaultOperand.loadFromData(t,e.defOperand),e.editor&&(this.defaultOperand.editor=t.getEditorById(e.editor)||new c),e.operands))for(var r=0;r<e.operands.length;r++){var o=new p;o.loadFromData(t,e.operands[r]),e.editor&&(o.editor=t.getEditorById(e.editor)||new c),this.operands.push(o)}},t}(),p=function(){function t(){this.kind=s.Scalar,this.dataType=o.g.Unknown,this.editor=new c,this.defValue=""}return t.prototype.loadFromData=function(t,e){this.kind=e.kind,this.dataType=e.dtype,this.defValue=e.val,this.defText=e.txt,e.editor&&(this.editor=t.getEditorById(e.editor)||new c)},t.prototype.copyFrom=function(t){o.P6.assign(this,t)},t}(),f=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),g=function(t){function e(e){var r=t.call(this,e)||this;return r.useInConditions=!1,r.useInResult=!1,r.useInSorting=!1,r}return f(e,t),e.prototype.loadFromData=function(e,r){t.prototype.loadFromData.call(this,e,r),r&&(this.useInConditions=r.uic,this.useInResult=r.uir,this.useInSorting=r.uis)},e.prototype.scan=function(e,r){t.prototype.scan.call(this,(function(t,r){return e&&e(t,r)}),(function(t,e){return r&&r(t,e)}))},e}(o.qR),y=function(t){function e(e){var r=t.call(this,e)||this;return r.params=[],r.useInConditions=!0,r.useInResult=!0,r.useInSorting=!0,r.defaultOperator="",r.operators=new Array,r.lookupAttr="",r.expr="",r}return f(e,t),e.prototype.loadFromData=function(e,r){t.prototype.loadFromData.call(this,e,r),r&&(this.useInConditions=r.uic,this.useInResult=r.uir,this.useInSorting=r.uis,this.expr=r.sql,this.defaultOperator=r.defOperator,this.operators=r.ops,r.udata&&(this.userData=r.udata))},e}(o.uF),m=function(){return m=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},m.apply(this,arguments)},v=m(m({},o.mb),{SqlList:"SQLLIST",SubQuery:"SUBQUERY",BindToParentColumn:"BINDTOPARENTCOLUMN"});!function(t){t[t.Unknown=0]="Unknown",t[t.Constant=1]="Constant",t[t.EntityAttribute=2]="EntityAttribute",t[t.ParentEntityAttribute=3]="ParentEntityAttribute",t[t.AggregateFunction=4]="AggregateFunction",t[t.ParentColumn=5]="ParentColumn",t[t.Query=11]="Query",t[t.CustomSql=21]="CustomSql"}(d||(d={}));var x,b,E,C=function(){function t(e){void 0===e&&(e=null),this.childs=[],this.value=null,this.parent=null,e&&(Array.isArray(e)?(this.value=e[0],e.length>1&&this.addChild(new t(e.slice(1)))):e instanceof t?(this.value=e.value,this.childs=e.childs):this.value=e)}return t.prototype.contains=function(t){if(this.value===t)return!0;for(var e=0,r=this.childs;e<r.length;e++){if(r[e].contains(t))return!0}return!1},t.prototype.findNode=function(t){if(this.value===t)return this;for(var e=0,r=this.childs;e<r.length;e++){var o=r[e].findNode(t);if(o)return o}return null},t.prototype.addChild=function(t){t.parent=this,this.childs.push(t)},t.prototype.setParents=function(){for(var t=0,e=this.childs;t<e.length;t++){var r=e[t];r.parent=this,r.setParents()}},t}(),T=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),w=function(t){function e(){var e=t.call(this)||this;return e.mainEntity=null,e.nullAttribute=new y(null),e.nullOperator=new h,e.operators=new Array,e.rootEntity=new g,e.aggrFunctions=new Array,e.dateMacros=["Today","Yesterday","Tomorrow","FirstDayOfMonth","LastDayOfMonth","FirstDayOfWeek","FirstDayOfYear","FirstDayOfNextWeek","FirstDayOfPrevMonth","FirstDayOfNextMonth","FirstDayOfNextYear","FirstDayOfPrevYear","FirstDayOfPrevWeek"],e.timeMacros=["Now","HourStart","Midnight","Noon"],e.links=[],e}return T(e,t),e.prototype.getMainEntity=function(){return this.mainEntity},e.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},e.prototype.loadFromData=function(e){if(t.prototype.loadFromData.call(this,e),this.operators=new Array,e.operators)for(var r=0;r<e.operators.length;r++){var o=new h;o.loadFromData(this,e.operators[r]),this.operators.push(o)}if(this.rootEntity.loadFromData(this,e.entroot),this.aggrFunctions=new Array,e.aggrfuncs)for(r=0;r<e.aggrfuncs.length;r++){var n=new u;n.loadFromData(e.aggrfuncs[r]),this.aggrFunctions.push(n)}},e.prototype.getObject=function(){return this},e.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},e.prototype.createEntity=function(t){return new g(t)},e.prototype.createEntityAttr=function(t){return new y(t)},e.prototype.createValueEditor=function(){return new c},e.prototype.createQuery=function(){return new k(this)},e.prototype.getRootEntity=function(){return this.rootEntity},e.prototype.getEditorById=function(e){return t.prototype.getEditorById.call(this,e)},e.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||null},e.prototype.getAttributeByIdSafe=function(t){var e=this.getAttributeById(t);return e||this.nullAttribute},e.prototype.checkAttrProperty=function(t,e){var r=this.getAttributeById(t);if(r){if(void 0===r[e])throw"No such property: "+e;return!!r[e]||!!r.lookupAttr&&(t=r.lookupAttr,(r=this.getAttributeById(t))&&r[e])}return!1},e.prototype.getEntityAttrById=function(e,r){return t.prototype.getEntityAttrById.call(this,e,r)},e.prototype._listByEntityWithFilter=function(t,e){var r,n=new Array,i=null;if(t.subEntities)for(var s=t.subEntities.length,a=0;a<s;a++){if(i=t.subEntities[a],!e||e(i,null))(r=o.ag.getText("Entities",i.name))||(r=i.caption),(d=o.P6.assign(new g,{id:i.name,text:r,items:[],isEntity:!0})).items=this._listByEntityWithFilter(i,e),d.items.length>0&&n.push(d)}var u=null;if(t.attributes)for(var l=t.attributes.length,c=0;c<l;c++)if(u=t.attributes[c],!e||e(t,u)){(r=o.ag.getText("Attributes",u.id))||(r=u.caption);var d=o.P6.assign(new g,{id:u.id,text:r,dataType:u.dataType});n.push(d)}return n},e.prototype._listByEntity=function(t,e,r){e=e||{};var n,i=[],s=[],a=null;if(t.subEntities)for(var u=t.subEntities.length,l=0;l<u;l++)if(a=t.subEntities[l],(!r||r(a,null))&&(!1!==e.addUIC&&!1!==a.useInConditions||!1!==e.addUIR&&!1!==a.useInResult||!1!==e.addUIS&&!1!==a.useInSorting)){n=o.ag.getText("Entities",a.name)||a.caption;var c=o.P6.assign(new g,{id:a.name,text:n,items:[],isEntity:!0,description:a.description}),d=o.P6.assign({},e);d.includeRootData=!1,c.items=this._listByEntity(a,d,r),c.items.length>0&&i.push(c)}var h=null;if(t.attributes)for(var p=t.attributes.length,f=0;f<p;f++)h=t.attributes[f],r&&!r(t,h)||(!1!==e.addUIC&&!1!==h.useInConditions||!1!==e.addUIR&&!1!==h.useInResult||!1!==e.addUIS&&!1!==h.useInSorting)&&(n=o.ag.getText("Attributes",h.id)||h.caption,s.push(o.P6.assign(new y(t),{id:h.id,text:n,dataType:h.dataType,lookupAttr:h.lookupAttr,description:h.description})));var m,v=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(i.sort(v),s.sort(v)),m=e.attrPlacement&&0!=e.attrPlacement?s.concat(i):i.concat(s),2==e.attrPlacement&&m.sort(v),e.includeRootData?((n=o.ag.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:m}):m},e.prototype.clear=function(){t.prototype.clear.call(this),this.operators=[],this.aggrFunctions=[]},e.prototype.addOrUpdateOperator=function(t){var e=o.P6.findItemById(this.operators,t.id);return e||((e=new h).id=t.id,this.operators.push(e)),e.caption=t.caption,e.expr=t.expr||"",e.displayFormat=t.format,e.defaultOperand=new p,e.defaultOperand.kind=t.kind||s.Scalar,t.appliedTypes&&(e.appliedTypes=t.appliedTypes),t.paramCount>0&&(e.paramCount=t.paramCount),this.runThroughEntities((function(t,r){t.operators.indexOf(e.id)<0&&e.appliedTypes.indexOf(t.dataType)>=0&&t.operators.push(e.id)})),e},e.prototype.removeOperator=function(t,e){void 0===e&&(e=!1);var r=o.P6.findItemById(this.operators,t);r&&(e||o.P6.removeArrayItem(this.operators,r),this.runThroughEntities((function(t,e){o.P6.removeArrayItem(t.operators,r.id)})))},e.prototype.getOperatorIdsByDataType=function(t){switch(t){case o.g.String:case o.g.Memo:return"StartsWith,EndsWith,Contains,Equal,InList,NotStartsWith,NotEndsWith,NotContains,NotEqual,NotInList,IsNull,IsNotNull".split(",");case o.g.Guid:return"Equal,NotEqual".split(",");case o.g.Date:case o.g.DateTime:return"DateWithinToday,DateWithinThisWeek,DateWithinPrevWeek,DateWithinThisMonth,DateWithinPrevMonth,DateWithinThisYear,DateWithinPrevYear,DateBeforePrecise,DateAfterPrecise,DatePeriodPrecise,IsNull,IsNotNull".split(",");case o.g.Time:return"TimeBeforePrecise,TimeAfterPrecise,TimePeriodPrecise,IsNull,IsNotNull".split(",");case o.g.Byte:case o.g.Word:case o.g.Int32:case o.g.Int64:case o.g.Float:case o.g.Currency:case o.g.BCD:case o.g.Autoinc:case o.g.Unknown:return"Equal,Between,LessThan,LessOrEqual,GreaterThan,GreaterOrEqual,InList,NotEqual,NotBetween,NotInList,IsNull,IsNotNull".split(",");case o.g.Bool:return"IsTrue,NotTrue".split(",");default:for(var e=[],r=0,n=this.operators;r<n.length;r++){var i=n[r];i.appliedTypes.indexOf(t)>=0&&e.push(i.id)}return e}},e.prototype.buildQueryPath=function(t){var e=this.mainEntity||this.rootEntity,r=this.createTreeNodeFromEntity(e);return r.setParents(),r},e.prototype.createTreeNodeFromEntity=function(t){for(var e=new C(t),r=0,o=t.subEntities;r<o.length;r++){var n=o[r];e.addChild(this.createTreeNodeFromEntity(n))}return e},e.prototype.getEntitiesInQuery=function(t){if(t.model.id!==this.id)throw Error("Model mithmatch");for(var e=[],r=0,o=t.getColumns();r<o.length;r++){var n=o[r];n.enabled&&this.addEntityByExpression(e,n.expr)}var i=t.getRootCondition();return this.fillEntitiesByCondtionGroup(e,i),e},e.prototype.findAggrFunctionById=function(t){for(var e=0,r=this.aggrFunctions;e<r.length;e++){var o=r[e];if(o.id===t)return o}return null},e.prototype.fillEntitiesByCondtionGroup=function(t,e){for(var r=0,o=e.getConditions();r<o.length;r++){var n=o[r];if(n.isGroup())this.fillEntitiesByCondtionGroup(t,n);else for(var i=0,s=n.expressions;i<s.length;i++){var a=s[i];if(this.addEntityByExpression(t,a),a.args)for(var u=0,l=a.args;u<l.length;u++){var c=l[u];this.addEntityByExpression(t,c)}}}},e.prototype.addEntityByExpression=function(t,e){if(e.tag===d.EntityAttribute){var r=e.baseAttrId||e.value;if(r){var n=this.getAttributeById(r);n&&n.entity&&o.P6.indexOfArrayItem(t,n.entity)<0&&t.push(n.entity)}}},e.prototype.findLink=function(t,e){for(var r=0,o=this.links;r<o.length;r++){var n=o[r];if(n.entityFrom==t&&n.entityTo==e)return n}return null},e.prototype.getLinksByEntity=function(t){for(var e=[],r=0,o=this.links;r<o.length;r++){var n=o[r];n.entityFrom!=t&&n.entityTo!=t||e.push(n)}return e},e.prototype.getEntitiesTree=function(t,e){return this._listByEntity(this.getRootEntity(),t,e)},e.prototype.getEntitiesTreeWithFilter=function(t){return this._listByEntityWithFilter(this.getRootEntity(),t)},e.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},e.prototype.getEntityPathByAttr=function(e,r,o,n){return t.prototype.getEntityPathByAttr.call(this,e,r,o,n)},e.prototype.getAttributeText=function(e,r){return t.prototype.getAttributeText.call(this,e,r)},e.prototype.getFirstUICAttr=function(){return this.getFirstUICAttrInEntity(this.getRootEntity())},e.prototype.getFirstUICAttrInEntity=function(t){if(!1!==t.useInConditions){if(t.attributes)for(var e=t.attributes.length,r=0;r<e;r++)if(t.attributes[r].useInConditions)return t.attributes[r];if(t.subEntities){var o=t.subEntities.length;for(r=0;r<o;r++){var n=this.getFirstUICAttrInEntity(t.subEntities[r]);if(n)return n}}}return null},e.prototype.runThroughEntities=function(t,e){this.getRootEntity().scan(t,e)},e.prototype.getFirstAttributeByFilter=function(t){var e=null;return this.runThroughEntities((function(r,o){t(r)&&(o.stop=!0,e=r)}),null),e},e.prototype.findOperatorById=function(t){if(this.operators.length>0)for(var e=this.operators.length,r=0;r<e;r++)if(this.operators[r].id==t)return this.operators[r];return null},e.prototype.getOperatorById=function(t){var e=this.findOperatorById(t);return e||this.nullOperator},e.prototype.getDefaultOperatorIdForAttr=function(t){return t.defaultOperator?t.defaultOperator:t.operators.length>0?t.operators[0]:this.nullOperator.id},e.prototype.getAggrFunctionCaption=function(t){var e=o.ag.getText("AggregateFunctions",t),r=e?e.caption:o.ag.getText("Aggr"+t.replace(" ","")+"_Caption");if(r)return r;var n=o.P6.findItemById(this.aggrFunctions,t);return n&&n.caption?n.caption:t},e.prototype.getAggrFunctionFormat=function(t){var e=o.ag.getText("AggregateFunctions",t),r=e?e.displayFormat:o.ag.getText("Aggr"+t.replace(" ","")+"_Format");if(r)return r;var n=o.P6.findItemById(this.aggrFunctions,t);return n&&n.displayFormat?n.displayFormat:""},e.prototype.getDefaultOperatorForAttr=function(t){var e=this.getDefaultOperatorIdForAttr(t);return this.getOperatorById(e)},e.prototype.getOperand=function(t,e,r){var n=new p;e&&e.defaultOperand?(n.copyFrom(e.defaultOperand),n.defValue||(n.defValue=""),n.defText||(n.defText="")):(n.kind=s.Scalar,n.dataType=t.dataType,n.defValue="",n.defText="",n.editor=null);var i=n;return i.dataType===o.g.Unknown&&t&&(i.dataType=t.dataType),e&&r>=0&&e.operands&&e.operands[r-1]&&(i=o.P6.assign(i,e.operands[r-1])),i.editor||(n.editor?i.editor=n.editor:n.kind===s.Query?i.editor.tag=v.SubQuery:t&&t.defaultEditor?i.editor=t.defaultEditor:i.dataType===o.g.Date||i.dataType===o.g.DateTime||i.dataType===o.g.Time?i.editor.tag=v.DateTime:i.editor.tag=v.Edit),i},e.prototype.getAggrFunctions=function(){return this.aggrFunctions},e.prototype.isDateMacro=function(t,e){var r=t.match(/\${{?(.*?)}?}/);if(null!=r){var n=r[1];if(o.P6.indexOfArrayItem(this.dateMacros,n)>=0)return e&&e(n),!0}return!1},e.prototype.isTimeMacro=function(t,e){var r=t.match(/\${{?(.*?)}?}/);if(null!=r){var n=r[1];if(o.P6.indexOfArrayItem(this.timeMacros,n)>=0)return e&&e(n),!0}return!1},e.prototype.getDateMacroValue=function(t){var e=new Date;return this.isDateMacro(t,(function(t){switch(t){case"Today":break;case"Yesterday":e.setDate(e.getDate()-1);break;case"Tomorrow":e.setDate(e.getDate()+1);break;case"FirstDayOfMonth":e.setDate(1);break;case"LastDayOfMonth":e.setMonth(e.getMonth()+1,0);break;case"FirstDayOfPrevWeek":r=0==(r=e.getDay())?1:8-r,e.setDate(e.getDate()-r);break;case"FirstDayOfWeek":r=0==(r=e.getDay())?6:r-1,e.setDate(e.getDate()-r);break;case"FirstDayOfYear":e.setMonth(0,1);break;case"FirstDayOfNextWeek":var r;r=0==(r=e.getDay())?1:8-r,e.setDate(e.getDate()+r);break;case"FirstDayOfNextMonth":e.setMonth(e.getMonth()+1,1);break;case"FirstDayOfPrevMonth":e.setMonth(e.getMonth()-1,1);break;case"FirstDayOfPrevYear":e.setFullYear(e.getFullYear()-1,0,1);break;case"FirstDayOfNextYear":e.setFullYear(e.getFullYear()+1,0,1)}}))?e:null},e.prototype.getDateOrMacroValue=function(t){var e=this.getDateMacroValue(t);return e||t},e.prototype.getTimeMacroValue=function(t){var e=new Date;return this.isDateMacro(t,(function(t){switch(t){case"Now":break;case"HourStart":e.setMinutes(0,0,0);break;case"Midnight":e.setHours(0,0,0,0);break;case"Noon":e.setHours(12,0,0,0)}}))?e:null},e.prototype.getTimeOrMacroValue=function(t){var e=this.getTimeMacroValue(t);return e||t},e.prototype.getAllDateMacros=function(){return this.dateMacros},e.prototype.getAllTimeMacros=function(){return this.timeMacros},e}(o.U4),I=function(){function t(t){var e=this;this.parent=t,this.tag=d.Constant,this.kind=s.Scalar,this.dataType=o.g.Unknown,this._value="",this.distinct=!1,this._isDefaultValue=!1,this.getText=function(){return e.text||e._value},this.args=new Array}return t.prototype.getParent=function(){return this.parent},t.prototype.getModel=function(){return this.parent.getQuery().getModel()},t.prototype.loadFromData=function(e,r){if(r)if(this.tag=r.tag,r.val?(this._value=r.val,this.text=r.txt):r.id&&(this.kind=s.Attribute,this._value=r.id,this.text=r.txt),void 0!==r.dtype&&(this.dataType=r.dtype),this.tag==d.EntityAttribute||this.tag==d.ParentEntityAttribute)this.kind=s.Attribute;else{if(void 0!==r.kind&&(this.kind=r.kind),r.query&&(this.subQuery=this.parent.getQuery().createSubQuery(),this.subQuery.loadFromDataOrJson(r.query)),void 0!==r.distinct&&(this.distinct=r.distinct),r.func&&(this.func=r.func,r.args))for(var o=0;o<r.args.length;o++){var n=new t(this.parent);n.loadFromData(e,r.args[o]),this.args.push(n)}r.sql&&(this.sql=r.sql,this.baseAttrId=r.baseAttrId)}},t.prototype.saveToData=function(){var t={tag:this.tag};if(t.dtype=this.dataType,this.tag==d.EntityAttribute||this.tag==d.ParentEntityAttribute)this._value&&(t.id=this._value,t.val=this._value),this.text&&(t.txt=this.text);else{if(this.subQuery&&(t.query=this.subQuery.toJSONData()),void 0!==this.kind&&(t.kind=this.kind),this._value&&(t.val=this._value),this.text&&(t.txt=this.text),this.distinct&&(t.distinct=this.distinct),this.func){t.func=this.func,t.args=[];for(var e=0;e<this.args.length;e++)t.args.push(this.args[e].saveToData())}this.sql&&(t.sql=this.sql,t.baseAttrId=this.baseAttrId)}return t},t.prototype.getIndex=function(){return this.parent.getExpressionIndex(this)},Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),t.prototype.setValue=function(t,e){void 0===e&&(e=!1),this.setContent(t,void 0,e)},t.prototype.setContent=function(t,e,r){void 0===r&&(r=!1);var o=this.value;if(this.kind==s.Attribute&&t){var n=this.getModel().getAttributeById(t);if(!n)throw"No such entity attribute:"+t;this.dataType=n.dataType}this._value=t,void 0!==e?this.text=e:void 0!==this.text&&(this.text=t),this._isDefaultValue=!1,r||this.parent.expressionChanged(this,o)},t.prototype.isEmpty=function(){return!(this.text||this._value)},t.prototype.hasText=function(){return this.text&&this.text.length>0},t.prototype.tryCopyValueFrom=function(t){if(this.kind==t.kind){if(this.dataType==t.dataType)this.setContent(t.value.length?t.value:this._value,t.text&&t.text.length?t.text:this.text,!0);else{var r=e.convertValue(t.value,t.dataType,this.dataType);this.setContent(r.length?r:this._value,t.text&&t.text.length?t.text:this.text,!0)}this.subQuery=t.subQuery,this.sql=t.sql,this.baseAttrId=t.baseAttrId}else this._isDefaultValue||(this.setContent("","",!0),this.subQuery=null,this.sql=null,this.baseAttrId=null)},t}();!function(t){t[t.Conditions=1]="Conditions",t[t.Columns=2]="Columns",t[t.SortingColumns=4]="SortingColumns",t[t.Properties=32]="Properties",t[t.ExtraData=64]="ExtraData",t[t.Facets=128]="Facets",t[t.Aggregation=256]="Aggregation",t[t.All=511]="All"}(x||(x={})),function(t){t[t.Add=1]="Add",t[t.Modify=2]="Modify",t[t.Delete=4]="Delete",t[t.Activate=8]="Activate",t[t.All=127]="All"}(b||(b={})),function(t){t[t.None=0]="None",t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(E||(E={}));var D,S,A=function(){function t(t,e){void 0===e&&(e=!1),this.query=t,this.justsorted=e,this.enabled=!0,this.params=[],this._isHidden=!1,this.query=t,this._id=o.P6.generateId("col"),this.caption="",this._sorting=E.None,this._sortIndex=-1,this.expr=new I(this),this.blockId="",this.justsorted=e}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sorting",{get:function(){return this.query?this.query.getColumnSorting(this):this._sorting},set:function(t){this.query?this.query.setColumnSorting(this,t):this._sorting=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sortIndex",{get:function(){return this.query?this.query.getColumnSortIndex(this):this._sortIndex},set:function(t){this.query?this.query.setColumnSortIndex(this,t):this._sortIndex=t},enumerable:!1,configurable:!0}),t.prototype.getModel=function(){return this.query.getModel()},t.prototype.getQuery=function(){return this.query},t.prototype.isReadOnly=function(){return!1},t.prototype.isJustSorted=function(){return this.justsorted},t.prototype.setReadOnly=function(t){},t.prototype.isHidden=function(){return this._isHidden},t.prototype.setHidden=function(t){this._isHidden=t},t.prototype.getDataType=function(){if(this.expr.dataType===o.g.Unknown){var t=null;if(this.expr.func){if("COUNT"==this.expr.func||"CNTDST"==this.expr.func)return o.g.Int64;t=this.expr.args[0].value}else t=this.expr.value;var e=this.query.getModel().getAttributeById(t);if(e)return e.dataType}return this.expr.dataType},t.prototype.loadFromData=function(t,e){e&&(e.id&&(this._id=e.id),this.caption=e.cptn,void 0!==e.srt&&(this._sorting=e.srt,this._sortIndex=void 0!==e.srtidx?e.srtidx:-1),!1===e.enabled&&(this.enabled=e.enabled),this.expr.loadFromData(t,e.expr),this.blockId=e.blockId,this.displayFormat=e.dfmt,this.groupFooterColumnTemlate=e.gfct,e.hidden&&this.setHidden(!0))},t.prototype.saveToData=function(){var t={};return t.id=this._id,void 0!==this.caption&&(t.cptn=this.caption),this.sorting!=E.None&&(t.srt=this.sorting,t.srtidx=this.sortIndex),t.expr=this.expr.saveToData(),this.blockId&&(t.blockId=this.blockId),!1===this.enabled&&(t.enabled=this.enabled),t.dfmt=this.displayFormat,t.gfct=this.groupFooterColumnTemlate,this.isHidden()&&(t.hidden=!0),t},t.prototype.fireChangedEvent=function(){this.query.fireChangedEvent({part:this.justsorted?x.SortingColumns:x.Columns,action:b.Modify,changee:this})},t.prototype.getExpressionIndex=function(t){return 0},t.prototype.expressionChanged=function(t,e){},t}();!function(t){t[t.Unknown=0]="Unknown",t[t.Simple=1]="Simple",t[t.Group=51]="Group"}(D||(D={})),function(t){t[t.EntityAttr=2]="EntityAttr",t[t.Operator=4]="Operator",t[t.Value=8]="Value",t[t.All=14]="All"}(S||(S={}));var _,O,F=function(){function e(e,r){this.query=e,this.linkType=t.All,this.parent=null,this._id=o.P6.generateId("cond"),this.justAdded=!1,this.tag=r||D.Unknown,this.enabled=!0,this.operatorId="",this.blockId="",this.expressions=new Array,this.conditions=new Array}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled&&(!this.getParent()||this.getParent().enabled)},set:function(t){this._enabled=t&&(!this.getParent()||this.getParent().enabled),this.conditions&&this.conditions.forEach((function(e){e.enabled=t}))},enumerable:!1,configurable:!0}),e.prototype.getQuery=function(){return this.query},e.prototype.getModel=function(){return this.query.getModel()},e.prototype.getParent=function(){return this.parent},e.prototype.setParent=function(t){this.parent=t},e.prototype.getConditions=function(){return this.conditions},e.prototype.isEmpty=function(){return 0===this.conditions.length},e.prototype.isGroup=function(){return this.tag==D.Group||null==this.parent},e.prototype.getLevel=function(){var t=this.getParent();return t?t.getLevel()+1:0},e.prototype.isReadOnly=function(){return!1},e.prototype.setReadOnly=function(t){},e.prototype.isParameterized=function(){return!1},e.prototype.setParameterized=function(t){},e.prototype.isInJoin=function(){return!1},e.prototype.setInJoin=function(t){},e.prototype.clearConditions=function(){this.conditions=[]},e.prototype.addCondition=function(t){return t.setParent(this),this.conditions.push(t)},e.prototype.removeConditionAt=function(t){this.conditions.splice(t,1)},e.prototype.loadFromData=function(t,e){if(e){if(this.tag=e.tag,this.tag||(this.tag=!this.parent||this.conditions.length>0?D.Group:D.Simple),void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.disabled&&(this.enabled=!e.disabled),this.tag==D.Simple&&(this.operatorId=e.op,e.exprs))for(var r=0;r<e.exprs.length;r++){var o=new I(this);o.loadFromData(t,e.exprs[r]),this.expressions.push(o)}this.linkType=e.linking}},e.prototype.saveToData=function(){var t={};if(t.tag=this.tag,this.enabled||(t.enabled=this.enabled),this.tag==D.Simple){t.op=this.operatorId,t.exprs=[];for(var e=0;e<this.expressions.length;e++)t.exprs.push(this.expressions[e].saveToData())}return this.tag==D.Group&&(t.linking=this.linkType),t},e.prototype.fireChangedEvent=function(t){void 0===t&&(t=S.All),this.query.fireChangedEvent({part:x.Conditions,action:b.Modify,changee:this,condPart:t})},e.prototype.getExpressionIndex=function(t){return this.expressions.indexOf(t,0)},e.prototype.expressionChanged=function(t,e){0==t.getIndex()&&t.tag==d.EntityAttribute&&this.tuneOperatorForAttr(t.value)},e.prototype.getOperatorId=function(){return this.operatorId},e.prototype.setOperatorId=function(t,e){void 0===e&&(e=!1);var r=this.operatorId;if(this.operatorId=t,!e){var o=this.getModel(),n=o.getOperatorById(t),i=this.expressions[0].value,s=o.getAttributeById(i);this.tuneValueExpressions(s,n,s.id,r)}},e.prototype.tuneOperatorForAttr=function(t){var e=this.getModel(),r=this.expressions[0].value,o=e.getAttributeById(r);if(null!=o){var n=this.getModel().getDefaultOperatorForAttr(o),i=this.operatorId;this.operatorId=n.id,this.tuneValueExpressions(o,n,t,i)}},e.prototype.tuneValueExpressions=function(t,e,r,n){var i=this.getModel();if(e){var s=this.expressions.length,a=(r&&i.getAttributeById(r),null);if(n&&(a=i.getOperatorById(n)),a&&a.paramCount==e.paramCount){for(var u=1;u<e.paramCount;){var l=i.getOperand(t,a,u);(g=i.getOperand(t,e,u)).dataType==o.g.Unknown&&(g.dataType=t.dataType);var d=g.editor&&g.editor.tag!==o.mb.Unknown?g.editor:t.defaultEditor&&t.defaultEditor.tag!==o.mb.Unknown?t.defaultEditor:new c;if(u>=s){var h=this.createValueExpr(g);this.expressions.push(h)}else{var p=this.expressions[u],f=this.createValueExpr(g);this.areCompitableEditors(l.editor,d)&&f.tryCopyValueFrom(p),this.expressions[u]=f}u++}s>u&&this.expressions.splice(u,s-u)}else{this.expressions.splice(1,this.expressions.length-1);for(u=1;u<e.paramCount;u++){var g;(g=i.getOperand(t,e,u)).dataType==o.g.Unknown&&(g.dataType=t.dataType);h=this.createValueExpr(g);this.expressions.push(h)}}}},e.prototype.areCompitableEditors=function(t,e){return e.tag!=v.CustomList&&e.tag!=v.List&&e.tag!=v.SqlList&&e.tag!=o.mb.Unknown},e.prototype.addExpressionByOperand=function(t,e){void 0===e&&(e=null);var r=this.createValueExpr(t,e);return this.expressions.push(r),r},e.prototype.createValueExpr=function(t,e){void 0===e&&(e=null);var r=null==e,o=e||t.defValue,n=e||t.defText,i=new I(this);if(t.kind===s.Query)i.tag=d.Query,i.dataType=t.dataType,i.kind=t.kind,i.setContent(o,n,!0);else if(t.kind===s.Attribute){if(!r){var a=this.getModel().getFirstAttributeByFilter((function(e){return 1==e.useInConditions&&(!t.dataType||e.dataType==t.dataType)}));o=a?a.id:null}i.tag=d.EntityAttribute,i.kind=t.kind,i.dataType=t.dataType,i.setContent(o,n,!0)}else r&&(o=t.defValue&&""!=t.defValue?t.defValue:t.editor&&t.editor.defValue?t.editor.defValue:"",t.editor&&(n=t.editor.getValueText(o))),i.tag=d.Constant,i.dataType=t.dataType,i.kind=t.kind,i.setContent(o,n,!0),i._isDefaultValue=r;return i},e}(),q=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),M=function(t){function e(r){var o=t.call(this,r)||this;return Error.captureStackTrace&&Error.captureStackTrace(o,e),o.name="InvalidQueryError",o}return q(e,t),e}(Error),k=function(){function r(t,e,r){var n=this;this.extraData={},this.innerData={},this.isNewbie=!0,this._isModified=!1,this._enableAggregation=!1,this.parentQuery=null,this.drillDowns=[],this.eventEmitter=new o.vp(this),this.root=new F(this,D.Group),this.extraConditions=new F(this,D.Group),this.columns=new Array,this.sortedColumns=new Array,this.id||this.regenerateId(),this.setDefaultName(),this.description="",this.model=t||new w,e&&this.loadFromData(e),this.attributeExprTag=r&&r.attrTag||d.EntityAttribute,this.clientListRequestHandler=r?r.clientListRequestHandler:new Array,this.serverListRequestHandler=r?r.serverListRequestHandler:new Array,this.timezoneOffset=(new Date).getTimezoneOffset(),this.aggrSettings=new o.$h(this),r&&(this.parentQuery=r.parent),this.addChangedCallback((function(t){t.data&&(t.data.part&x.Columns)>0&&!t.data.aggregation&&n._enableAggregation&&n.updateAggregationSettings()&&n.fireChangedEvent({part:x.Aggregation})}))}return r.prototype.isModified=function(){return this._isModified},r.prototype.resetModified=function(){this._isModified=!1},Object.defineProperty(r.prototype,"enableAggregation",{get:function(){return this._enableAggregation},set:function(t){var e=this._enableAggregation;if(this._enableAggregation=t,!e&&t){this.processQueryForAggregation();this.columns.filter((function(t){return t.enabled&&t.expr.tag==d.AggregateFunction}))}this._enableAggregation||this.aggrSettings.clear()},enumerable:!1,configurable:!0}),r.prototype.updateAggregationSettings=function(){for(var t=!1,e=this.getAggregationSettings(),r=e.groups.length-1;r>=0;r--){for(var o=e.groups[r],n=function(e){var r=o.columns[e];i.columns.find((function(t){return t.id===r}))||(o.columns.splice(e,1),t=!0)},i=this,s=o.columns.length-1;s>=0;s--)n(s);0==o.columns.length&&e.groups.slice(r,1)}var a=e.getAggregates(),u=function(e){var r=a[e];l.columns.find((function(t){return t.id===r.colId}))||(a.splice(e,1),t=!0)},l=this;for(r=a.length-1;r>=0;r--)u(r);return t},r.prototype.createSubQuery=function(){return new r(this.model)},r.prototype.useAggregation=function(t,e){if(void 0===e&&(e=!1),this.aggrSettings.clear(),t(this.aggrSettings),this.enableAggregation)this.processQueryForAggregation(e);else if(!e)return void console.warn("Aggregation is turned off. Turn it on with query.enableAggregation = true")},r.prototype.useDefaultAggregation=function(){var t=this;this._enableAggregation=!0,this.useAggregation((function(e){var r=t.columns.filter((function(t){return t.enabled&&t.expr.tag==d.AggregateFunction}));if(r.length){for(var n=t.columns.filter((function(t){return t.enabled&&t.expr.tag==d.EntityAttribute})),i=[],s=0,a=r;s<a.length;s++){var u=a[s];i.push({id:u.id,func:u.expr.func}),t.changeColumnType(u,d.EntityAttribute)}for(var l=0,c=i;l<c.length;l++){var h=c[l];e.addAggregateColumn(h.id,h.func)}for(var p=0,f=n;p<f.length;p++){u=f[p];e.addGroup({columns:[u.id],name:u.caption})}e.addGrandTotals(),t.fireChangedEvent({part:x.Columns,wasModified:!1})}else{var g=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==d.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===o.g.Currency}))[0],y=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==d.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===o.g.String}))[0];if(!g&&!e.hasAggregates()||!y)return;e.addGrandTotals().addAggregateColumn(g.id,"SUM").addGroup({columns:[y.id],name:"Default"})}}))},r.prototype.processQueryForAggregation=function(t){var e=this;void 0===t&&(t=!1);var r=this.getAggregationSettings().getGroups();if(r.length>0){for(var o=r[r.length-1].columns,n=[],i=[],s=0,a=this.getColumns();s<a.length;s++){var u=a[s];o.indexOf(u.id)>=0?n.push(u):this.getColumnSorting(u)!=E.None&&i.push(u)}var l=0;n.forEach((function(t){e.getColumnSorting(t)==E.None&&e.setColumnSorting(t,E.Ascending),e.setColumnSortIndex(t,l++)})),i.forEach((function(t){e.setColumnSortIndex(t,l++)})),t||this.fireChangedEvent({part:x.Columns,aggregation:!0,wasModified:!1})}},r.prototype.getAggregationSettings=function(){return this.aggrSettings},r.prototype.getColumnIds=function(t,e){return e=e||t,this.columns.slice(t,e-t+1).map((function(t){return t.id}))},r.prototype.validateColumns=function(t){for(var e=this.columns.filter((function(t){return t.enabled})).map((function(t){return t.id})),r=-1,o=0,n=t;o<n.length;o++){var i=n[o],s=e.indexOf(i);if(s<0)return!1;if(r>s)return!1;r=s}return!0},r.prototype.validateAggregate=function(t,e){var r=this.columns.filter((function(e){return e.enabled&&e.id===t}))[0],o=this.model.findAggrFunctionById(e);return!(!o||!r||o.appliedTypes.indexOf(r.expr.dataType)<0)},r.prototype.isEx=function(){return!1},r.prototype.reset=function(t){void 0===t&&(t=!0),t&&this.clear(),this.regenerateId(),this.setDefaultName(),this._isModified=!1,this.isNewbie=!0},r.prototype.hasEnabledAggrColumns=function(){return this.columns.filter((function(t){return t.enabled&&t.expr.tag===d.AggregateFunction})).length>0},r.prototype.setDefaultName=function(){return this.setName(o.ag.getText("NewQueryName")),this.getName()},r.prototype.validate=function(t){t=t||{};var e="EntityAttribute isn't declared in the model: ";if(!this.model)throw new M("Model is not declared");if(this.columns)for(var r=0,o=this.columns;r<o.length;r++){var n=o[r];if(n.expr.tag==d.EntityAttribute||n.expr.tag===d.ParentEntityAttribute){if(!this.model.getAttributeById(n.expr.value))throw new M(e+n.expr.value)}else if(n.expr.tag===d.AggregateFunction){if(!this.model.getAttributeById(n.expr.args[0].value))throw new M(e+n.expr.args[0].value)}else if(n.expr.tag!==d.CustomSql)throw new M("The expression has wrond tag: "+n.expr.tag)}this.root&&this.root.getConditions()&&this.validateConditionGroup(this.root,t)},r.prototype.getAggregatedColumns=function(){return this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===d.AggregateFunction}))},r.prototype.tryValidate=function(t){try{return this.validate(t),!0}catch(t){if(t instanceof M)return!1;throw t}},r.prototype.validateConditionGroup=function(t,e){if(t.isGroup())for(var r=0,n=t.getConditions();r<n.length;r++){var i=n[r];i.enabled&&this.validateConditionGroup(i,e)}else if(t.expressions[0].tag===d.EntityAttribute){var a=t.expressions[0].value;if(!this.model.getAttributeById(a))throw new M("EntityAttribute isn't declared in the model: "+a);if(!e.checkExpressions)return;for(var u=1;u<t.expressions.length;u++){var l=t.expressions[u];if(l.tag===d.Constant&&o.P6.isNumericType(l.dataType)){if(!l.value)continue;for(var c=0,h=l.kind===s.List?l.value.split(/\s*,\s*/):[l.value];c<h.length;c++){var p=h[c],f=+p;if(isNaN(f))throw new M("Expression constant is NaN in condition:"+t.id);if(o.P6.isIntType(l.dataType)&&f!=parseInt(p,10))throw new M("Expression constant is wrong interger in condition: "+t.id)}}}}},r.prototype.loadFromDataOrJson=function(t,e){t&&("string"==typeof t?this.loadFromJson(t,e):this.loadFromData(t,e))},r.prototype.loadFromJson=function(t,e){var r=JSON.parse(t);this.loadFromData(r,e)},r.prototype.loadFromData=function(t,e){var r=this;e=o.P6.assign({changeStatus:!0,validate:!0},e||{});if(this.clear(),this.clearDrillDowns(),t){if(this.id=t.id,this.root.loadFromData(this.model,t.root),t.root&&t.root.conds)for(var n=0;n<t.root.conds.length;n++){var i=t.root.conds[n];if(!i.conds||this.isEx()){var s=this.createCondition();s.loadFromData(this.model,i),this.root.addCondition(s)}else console.error("Community version doesn't support working with groups.")}if(this.name=t.name,this.description=t.desc,this.sortedColumns=[],t.justsortcols)for(n=0;n<t.justsortcols.length;n++){(a=this.createColumn(!0)).loadFromData(this.model,t.justsortcols[n]),this.addColumnToSorted(a)}if(t.cols)for(n=0;n<t.cols.length;n++){var a;(a=this.createColumn()).loadFromData(this.model,t.cols[n]),this.columns.push(a),a._sorting!=E.None&&this.addColumnToSorted(a)}if(this.sortedColumns.sort((function(t,e){return t.sortIndex-e.sortIndex})),this.fixupSortingIndices(),t.extraData&&(this.extraData=t.extraData),this.innerData=t.innerData||this.innerData,this.innerData&&this.innerData.aggr&&(this._enableAggregation=this.innerData.aggr.enabled||!1,this.useAggregation((function(t){t.loadFromData(r.innerData.aggr)}),!0)),t.dds&&t.dds.length)for(var u=0,l=t.dds;u<l.length;u++){var c=l[u];this.addDrillDown().loadFromData(c)}}e.changeStatus&&(this.isNewbie=!1,this._isModified=!1),e.validate&&this.validate()},r.prototype.addDrillDown=function(){var t=this.model.createQuery();return t.parentQuery=this,this.drillDowns.push(t),t},r.prototype.getDrillDowns=function(){return this.drillDowns},r.prototype.getParentQuery=function(){return this.parentQuery},r.prototype.findColumnById=function(t){for(var e=0,r=this.columns;e<r.length;e++){var o=r[e];if(o.id===t)return o}return null},r.prototype.getModel=function(){return this.model},r.prototype.setModel=function(t){this.model=t},r.prototype.loadModelData=function(t){this.model.setData(t)},r.prototype.toJSON=function(){return JSON.stringify(this.toJSONData())},r.prototype.toJSONData=function(){var t=this;this.fixupSortingIndices();var e={modelId:this.model?this.model.getId():null,modelName:this.model?this.model.getName():null};e.id=this.id,e.name=this.name,this.description&&(e.desc=this.description),e.cols=[];for(var r=0;r<this.columns.length;r++)e.cols.push(this.columns[r].saveToData());e.justsortcols=[],this.sortedColumns.forEach((function(t){t.isJustSorted()&&e.justsortcols.push(t.saveToData())})),this.extraData&&(e.extraData=this.extraData),this.innerData&&(e.innerData=this.innerData,e.innerData.aggr=this.aggrSettings.saveToData(),e.innerData.aggr.enabled=this._enableAggregation);var n=function(e){var r=e.saveToData();r.conds=[];for(var o=e.getConditions(),n=0;n<o.length;n++)!o[n].isGroup()||t.isEx()?r.conds.push(o[n].saveToData()):console.error("Community version doesn't support working with groups.");return r};if(e.root=n(this.root),e.extraConds=n(this.extraConditions),this.drillDowns.length>0){e.dds=[];for(var i=0,s=this.drillDowns;i<s.length;i++){var a=s[i];e.dds.push(a.toJSONData())}}return e.timezoneOffset=this.timezoneOffset,e.locale=o.ag.getCurrentLocale(),e},r.prototype.isEmptyConditions=function(){return this.root.isEmpty()},r.prototype.isEmptyColumns=function(){return!this.columns||0===this.columns.length},r.prototype.isEmpty=function(){return this.isEmptyColumns()&&this.isEmptyConditions()},r.prototype.clear=function(){this._enableAggregation=!1,this.aggrSettings.clear(),this.clearColumns(),this.clearConditions(),this.clearExtraConditions(),this.innerData={},this.extraData={}},r.prototype.clearColumns=function(){this.columns=[],this.sortedColumns=[]},r.prototype.clearConditions=function(){this.root.clearConditions(),this.root.linkType=t.All,this.root.enabled=!0},r.prototype.clearExtraConditions=function(){this.extraConditions.clearConditions()},r.prototype.clearDrillDowns=function(){this.drillDowns=[]},r.prototype.getId=function(){return this.id},r.prototype.setId=function(t){this.id=t},r.prototype.regenerateId=function(){this.id=o.P6.generateId("quer")},r.prototype.getName=function(){return this.name},r.prototype.setName=function(t){this.name=t},r.prototype.getDescription=function(){return this.description},r.prototype.setDescription=function(t){this.description=t},r.prototype.getColumns=function(){return this.columns},r.prototype.getUsedInTotalsColumns=function(){if(0===this.getAggregatedColumns().length)return[];var t=this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===d.EntityAttribute}));return t.length&&t.pop(),t},r.prototype.addColumnToSorted=function(t){var e=JSON.stringify(t.expr.saveToData()),r=!0;this.sortedColumns.forEach((function(t){JSON.stringify(t.expr.saveToData())===e&&(r=!1)})),r&&this.sortedColumns.push(t)},r.prototype.getJustSortedColumns=function(){return this.sortedColumns.filter((function(t){return t.isJustSorted()}))},r.prototype.getSortedColumns=function(){return this.sortedColumns},r.prototype.getColumnSortIndex=function(t){return this.sortedColumns.indexOf(t)},r.prototype.setColumnSortIndex=function(t,e){if(!(e<0)){var r=this.getColumnSortIndex(t);r<0&&(this.addColumnToSorted(t),r=this.sortedColumns.length-1),o.P6.moveArrayItem(this.sortedColumns,r,e),this.fixupSortingIndices()}},r.prototype.getColumnSorting=function(t){return this.getColumnSortIndex(t)>=0?t._sorting!=E.None?t._sorting:E.Ascending:E.None},r.prototype.setColumnSorting=function(t,e){var r=this.getColumnSortIndex(t);t._sorting=e,r>=0?e==E.None&&(o.P6.removeArrayItem(this.sortedColumns,t),this.fixupSortingIndices()):e!=E.None&&(this.addColumnToSorted(t),this.fixupSortingIndices())},r.prototype.fixupSortingIndices=function(){this.sortedColumns.forEach((function(t,e){t._sortIndex=e}))},r.prototype.createColumn=function(t){return void 0===t&&(t=!1),new A(this,t)},r.prototype.getColumnById=function(t){return o.P6.findItemById(this.columns,t)},r.prototype.addColumn=function(t,e){var r;if(t.column)r=t.column;else{r=this.createColumn(t.justsorted);var n=void 0;if(t.attribute)n=t.attribute;else{if(!t.attributeId)throw new Error("Not enought data for addColumn operation. Need attribute or attributeId");if(!(n=this.model.getAttributeById(t.attributeId)))throw new Error("Incorrect attribute id (".concat(t.attributeId,"): addColumn"))}if(!n.useInResult&&(n.lookupAttr&&(n=this.model.getAttributeById(n.lookupAttr)),!n||!n.useInResult))throw new Error("Can't use this attribute for a column");if(t.aggrFuncId&&t.cusomtSql&&console.warn("Column cannot be created using aggrFuncId and customSql at the same time. cusomSql will be used."),t.cusomtSql)r.caption="Custom SQL Column",r.expr.tag=d.CustomSql,r.expr.baseAttrId=n.id,r.expr.sql=t.cusomtSql,r.expr.kind=s.Query,r.expr.dataType=o.g.Unknown;else if(t.aggrFuncId){var i=t.aggrFuncId;r.caption=n.caption+" "+this.model.getAggrFunctionCaption(t.aggrFuncId),r.expr.tag=d.AggregateFunction,r.expr.func=t.aggrFuncId,r.expr.kind=s.Scalar,r.expr.dataType="COUNT"==i||"CNTDST"==i?4:n.dataType,r.expr.distinct=!1;var a=new I(r);a.setValue(n.id,!0),a.tag=d.EntityAttribute,a.dataType=n.dataType,r.expr.args.push(a)}else r.caption=n.caption,r.expr.setValue(n.id,!0),r.expr.tag=d.EntityAttribute,r.expr.dataType=n.dataType;r.caption=t.caption||r.caption,r._sorting=t.sorting||E.None,r._sortIndex=t.sortIndex||-1,r.enabled=o.P6.getIfDefined(t.enabled,!0),r.setReadOnly(o.P6.getIfDefined(t.readonly,!1))}var u=t.justsorted||t.column&&t.column.isJustSorted();return u||(t.index&&t.index>=0&&t.index<this.columns.length?this.columns.splice(t.index,0,r):this.columns.push(r)),this.setColumnSorting(r,r._sorting),this.fireColumnsChangedEvent(b.Add,r,u),r},r.prototype.addColumnObj=function(t,e,r){var o=this,n=this.columns;void 0===t.length?("number"==typeof e?n.splice(e,0,t):n.push(t),t.sorting!=E.None&&this.addColumnToSorted(t),this.fixupSortingIndices()):("number"==typeof e?n.push.apply(n,[e,0].concat(t)):n.push.apply(n,[].concat(t)),t.forEach((function(t){t.sorting!=E.None&&o.addColumnToSorted(t)})),this.fixupSortingIndices())},r.prototype.changeColumnType=function(t,e,r){if(!t.isJustSorted())if(r=r||{},t.caption=void 0!==r.caption?r.caption:"",e===d.AggregateFunction){if(!r.funcId)throw Error('"funcId" argument is not defined');if(t.expr.tag==d.AggregateFunction)return void(t.expr.func=r.funcId);(u=new I(t)).tag=d.AggregateFunction,u.func=r.funcId,u.distinct=!1,u.dataType="COUNT"==r.funcId||"CNTDST"==r.funcId?4:t.expr.dataType;var n=new I(t);n.loadFromData(this.model,t.expr.saveToData()),u.args.push(n),t.expr=u}else if(e===d.CustomSql){var i=t.expr.tag==d.AggregateFunction?t.expr.args[0].value:t.expr.value,s="";this.model&&(s=this.model.getAttributeById(i).expr);var a=new I(t);a.tag=d.CustomSql,a.dataType=o.g.String,a.sql=s,a.baseAttrId=i,t.expr=a}else if(e===d.EntityAttribute){if(t.expr.tag===d.EntityAttribute||t.expr.tag===d.ParentEntityAttribute)return;var u,l=t.expr.tag===d.CustomSql?t.expr.baseAttrId:t.expr.args[0].value,c=this.model.getAttributeById(l);(u=new I(t)).tag=d.EntityAttribute,u.dataType=null!=c?c.dataType:o.g.Unknown,u.setValue(l,!0),t.expr=u}},r.prototype.moveColumn=function(t,e){var r=this.getColumns();o.P6.moveArrayItem(r,t,e)},r.prototype.removeColumn=function(t,e){o.P6.removeArrayItem(this.columns,t),o.P6.removeArrayItem(this.sortedColumns,t)},r.prototype.addConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},r.prototype.addExtraConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},r.prototype.createCondition=function(t){return void 0===t&&(t=D.Simple),new F(this,t)},r.prototype.addSimpleCondition=function(t){var e=t.parent||this.getRootCondition(),r=this.getModel();if(!r)return null;if(!t.attribute&&!t.attributeId)throw new Error("Either `attribute` or `attributeId` parameter must have a value");if(!t.attribute&&(t.attribute=r.getAttributeById(t.attributeId),!t.attribute))throw new Error("Could not find this attribute: "+t.attributeId);!t.operator&&t.operatorId&&(t.operator=r.getOperatorById(t.operatorId)),t.operator||(t.operator=r.getDefaultOperatorForAttr(t.attribute));var n=this.createSimpleConditionObject(t.attribute,t.operator,t.value);return e.addCondition(n),n.enabled=o.P6.getIfDefined(t.enabled,!0),n.setReadOnly(o.P6.getIfDefined(t.readonly,!1)),n},r.prototype.addSimpleExtraCondition=function(t){return t.parent=t.parent||this.extraConditions,this.addSimpleCondition(t)},r.prototype.createSimpleConditionObject=function(t,e,r){if(!t||!t.useInConditions)throw"Can't add a condition with such attribute: "+(t?t.caption:"NULL");var n=this.createCondition(D.Simple);n.setOperatorId(e.id,!0);var i=new I(n);i.setValue(t.id,!0),i.tag=this.attributeExprTag,i.kind=s.Attribute,i.dataType=t.dataType,n.expressions.push(i);var a=this.getModel(),u=e.paramCount,l=o.P6.fillArray(new Array(u-1),null);null!=r&&(Array.isArray(r)?o.P6.copyArrayTo(r,l):u>0&&(l[0]=r));for(var c=l.length,d=0;d<c;d++){var h=a.getOperand(t,e,d+1);n.addExpressionByOperand(h,l[d])}return n},r.prototype.removeColumns=function(t,e){var r=t.filter((function(t){return t.isJustSorted()})),o=t.filter((function(t){return!t.isJustSorted()}));function n(t,e){for(var r=e.length,o=0;o<r;o++){var n=t.indexOf(e[o]);n>=0&&t.splice(n,1)}}o.length>0&&(n(this.getColumns(),o),n(this.sortedColumns,o)),r.length>0&&n(this.sortedColumns,r),this.fixupSortingIndices()},r.prototype.fireProcessEvent=function(t){this.eventEmitter.fire("query.process",t)},r.prototype.fireChangedEvent=function(t,e,r){t=t||{part:x.All},void 0===e&&void 0===r||(t.postpone=e||0,t.wasModified=r,console.warn("Method with 'postpone' and 'wasModified' args is deprecated. Pass params in data object")),this._isModified=void 0===t.wasModified||t.wasModified;var o=t||{part:x.All};this.eventEmitter.fire("query.change",o,t.postpone||0)},r.prototype.fireColumnsChangedEvent=function(t,e,r){void 0===r&&(r=!1),this.fireChangedEvent({part:r?x.SortingColumns:x.Columns,action:t,changee:e})},r.prototype.fireConditionsChangedEvent=function(t,e){this.fireChangedEvent({part:x.Conditions,action:t,changee:e})},r.prototype.runThroughConditions=function(t){var e=function(r){for(var o=0;o<r.getConditions().length;o++){var n=r.getConditions()[o];n.isGroup()?e(n):t&&t(n)}};e(this.getRootCondition())},r.prototype.getOneValueForAttr=function(t){var e=null;return this.runThroughConditions((function(r){if(r.enabled){var o=r.expressions[0],n=r.getOperatorId();o.value!=t||!r.expressions[1]||"Equal"!=n&&"InList"!=n&&"StartsWith"!=n||(e=r.expressions[1].value)}})),e},r.prototype.getRootCondition=function(){return this.root},r.prototype.addProcessCallback=function(t){return this.eventEmitter.subscribe("query.process",t)},r.prototype.removeProcessCallback=function(t){this.eventEmitter.unsubscribe("query.process",t)},r.prototype.addChangedCallback=function(t){return this.eventEmitter.subscribe("query.change",t)},r.prototype.removeChangedCallback=function(t){this.eventEmitter.unsubscribe("query.change",t)},r.prototype.getConditionsText=function(){var r=this,n=this.getModel();if(!n)return"";var i=function(a){var u,l,c="",h="Conj"+e.linkTypeToStr(a.linkType),p=o.ag.getText(h);for(l=0;l<a.getConditions().length;l++){u="";var f=a.getConditions()[l];if(f.enabled||void 0===f.enabled)if(f.isGroup())(u=i(f))&&(u="("+u+")");else for(var g=f.getOperatorId(),y=n.getOperatorById(g),m=e.parseOperatorFormat(y),v=m.length,x=0;x<v;x++){var b=m[x],E=b.text;if("expression"==b.type){var C=f.expressions[b.index];if(C.kind==s.Attribute||C.tag==d.EntityAttribute){var T=n.getAttributeById(C.value);E=n.getAttributeText(T,"{entity} {attr}")}else if(E=C.getText(),r.model.isDateMacro(E)||r.model.isTimeMacro(E)){var w=E.substring(3,E.length-2);E=o.ag.getText(w)||E}}x>0&&(u+=" "),u+=E}u&&(l>0&&c&&(c+=" "+p+" "),c+=u)}return a.linkType!=t.None&&a.linkType!=t.NotAll||(c="not ( "+c+" )"),c};return i(this.getRootCondition())},r.prototype.getConditionsTextAsHtml=function(){var r=this,n=this.getModel();if(!n)return'<div class="eqjs-query-text"></div>';var i=function(t){if(t.kind==s.Query)return"<".concat(t.getText(),">");if(t.kind==s.List)return"[".concat(t.getText(),"]");if(t.dataType==o.g.String||t.dataType==o.g.Memo||t.dataType==o.g.FixedChar)return""".concat(t.getText(),""");var e=t.getText();if(r.model.isDateMacro(e)||r.model.isTimeMacro(e)){var n=e.substring(3,e.length-2);e=o.ag.getText(n)||e}return e},a=function(r){var u,l,c="",h="Conj"+e.linkTypeToStr(r.linkType),p='<span class="eqjs-query-text-conj">'.concat(o.ag.getText(h),"</span>");for(l=0;l<r.getConditions().length;l++){u="";var f=r.getConditions()[l];if(f.enabled||void 0===f.enabled)if(f.isGroup())(u=a(f))&&(u="("+u+")");else for(var g=f.getOperatorId(),y=n.getOperatorById(g),m=e.parseOperatorFormat(y),v=m.length,x=0;x<v;x++){var b=m[x],E=b.text;if("expression"==b.type){var C=f.expressions[b.index];if(C.kind==s.Attribute||C.tag==d.EntityAttribute){var T=n.getAttributeById(C.value);E='<span class="eqjs-query-text-attr">'.concat(n.getAttributeText(T,"{entity} {attr}"),"</span>")}else E='<span class="eqjs-query-text-expr">'.concat(i(C),"</span>")}else"operator"==b.type&&(E='<span class="eqjs-query-text-op">'.concat(E,"</span>"));x>0&&(u+=" "),u+=E}u&&(l>0&&c&&(c+=" "+p+" "),c+=u)}return r.linkType!=t.None&&r.linkType!=t.NotAll||(c='<span class="eqjs-query-text-conj">not</span> ( '+c+" )"),c};return'<div class="eqjs-query-text">'.concat(a(this.getRootCondition()),"</div>")},r}(),P=function(){function t(t){this.context=t,console.warn("BrowserQueryStorage is used for managing queries")}return t.prototype.init=function(t){var e="eq";t&&t.keyPrefix&&(e=t.keyPrefix),this.queryListKey=e+"-querylist",this.queryKeyPrefix=e},t.prototype.getQueryList=function(t){var e=this;return new Promise((function(t,r){try{var o=localStorage.getItem(e.queryListKey);o&&t(JSON.parse(o)),t([])}catch(t){r(t)}}))},t.prototype.newQuery=function(t){var e=this;return new Promise((function(r,o){var n=new k(e.context.getModel());n.reset(),n.setDefaultName(),t&&(t.query&&n.loadFromData(t.query.toJSONData()),t.queryId&&n.setId(t.queryId),t.name&&n.setName(t.name),t.description&&n.setDescription(t.description)),e._saveQuery(n),r(n.toJSONData())}))},t.prototype.loadQuery=function(t){var e=this;return new Promise((function(r,o){try{var n=localStorage.getItem(e.queryKeyPrefix+"-"+t.queryId);throw n&&r(JSON.parse(n)),new Error("Query is not found: "+t.queryId)}catch(t){o(t)}}))},t.prototype.saveQuery=function(t){var e=this;return new Promise((function(r,o){try{t.modelId||e.context.getModel().getId();var n=t.query||e.context.getQuery();e._saveQuery(n),r(null)}catch(t){o(t)}}))},t.prototype._saveQuery=function(t){var e=[],r=localStorage.getItem(this.queryListKey);r&&(e=JSON.parse(r));var n=o.P6.findItemById(e,t.getId());n||(n={id:t.getId(),name:t.getName(),text:t.getDescription()},e.push(n)),n.name=t.getName(),n.text=t.getDescription(),localStorage.setItem(this.queryListKey,JSON.stringify(e)),localStorage.setItem(this.queryKeyPrefix+"-"+t.getId(),t.toJSON())},t.prototype.removeQuery=function(t){var e=this;return new Promise((function(r,o){try{t.modelId||e.context.getModel().getId();var n=t.queryId||e.context.getQuery().getId(),i=[],s=localStorage.getItem(e.queryListKey);s&&(i=JSON.parse(s)),i=i.filter((function(t){return t.id!=n})),localStorage.setItem(e.queryListKey,JSON.stringify(i)),localStorage.removeItem(e.queryKeyPrefix+"-"+n),r()}catch(t){o(t)}}))},t}(),L=function(){function t(t){this.context=t,this.modelPromise=null}return t.prototype.init=function(t){},t.prototype.getContext=function(){return this.context},t.prototype.createModelLoadingPromise=function(){var t=this;this.modelPromise=new Promise((function(e,r){t.modelLoadingResolveFunc=e,t.modelLoadingRejectFunc=r}))},t.prototype.getModelPromise=function(){return this.modelPromise||Promise.reject(new Error("Model has been never loaded."))},t.prototype.startModelLoading=function(t){return this.createModelLoadingPromise(),this.sendLoadModelRequest(t),this.modelPromise},t}(),R=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),N=function(t){function e(e){return t.call(this,e)||this}return R(e,t),e.prototype.init=function(){},e.prototype.sendLoadModelRequest=function(t){var e=this,r=this.getContext(),o=r.getServices().getHttpClient(),n=r.resolveEndpoint("GetModel",{modelId:t.modelId});o.get(n).then((function(t){t.model||e.modelLoadingRejectFunc(new Error('Wrong response format for "GetModel" request')),e.modelLoadingResolveFunc(t.model)})).catch((function(t){e.modelLoadingRejectFunc(t)}))},e}(L),Q=function(){function t(t){this.context=t}return t.prototype.fetchData=function(t){var e=t.query||this.context.getQuery(),r=e.getId(),o={options:t.options};void 0!==t.queryId?o.queryId=t.queryId:o.query=e.toJSONData(),t.debug&&(o.debug=t.debug),t.chunk&&(o.chunk=t.chunk),t.data&&(o.data=t.data),void 0!==t.aux&&(o.aux=t.aux);var n=this.context.resolveEndpoint("FetchData",{modelId:e.getModel().getId(),queryId:r});return this.context.getServices().getHttpClient().post(n,o).then((function(t){return t}))},t}(),B=function(){function t(t){this.context=t}return t.prototype.syncQuery=function(t){var e=(t=t||{}).query||this.context.getQuery(),r=t.options||{},o={query:e.toJSONData(),options:r};t.data&&(o.data=t.data);var n=this.context.resolveEndpoint("SyncQuery",{modelId:e.getModel().getId(),queryId:e.getId()});return this.context.getServices().getHttpClient().post(n,o).then((function(t){return t}))},t}(),j=function(){function t(t){this.context=t}return t.prototype.loadValueList=function(t){var e=t.modelId||this.context.getModel().getId(),r=o.P6.assign({modelId:e},t.params).editorId,n=this.context.getServices().getHttpClient(),i=this.context.resolveEndpoint("GetValueList",{modelId:e,listId:r}),s={};return t&&t.params&&t.params.queryParams&&(s=t.params.queryParams),n.get(i,{queryParams:s}).then((function(t){if(t&&t.values)return t.values;throw new Error('Wrong response format. No "values" property')}))},t}(),G=function(){function t(t){this.context=t}return t.prototype.getQueryFile=function(t){var e=t.query||this.context.getQuery(),r=this.context.resolveEndpoint("GetQueryFile",{modelId:e.getModel().getId(),format:t.format||"xml"}),o=this.context.getServices().getHttpClient().post(r,{query:e.toJSONData()}),n=o.getRequest();return o.then((function(e){var r=new Blob([e]),o=n.getXMLHttpRequest().getResponseHeader("Content-Disposition"),i=o?o.match(/filename="(.*)"/)[1]:"query.json";if(t.fileName&&(i=t.fileName+i.substring(i.lastIndexOf("."))),window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,i);else{var s=document.createElement("a");document.body.appendChild(s),s.style.display="none",s.href=window.URL.createObjectURL(r),s.download=i,s.click(),window.URL.revokeObjectURL(s.href),document.body.removeChild(s)}}))},t.prototype.uploadQueryFile=function(t){var e=(t=t||{}).query||this.context.getQuery(),r=this.context.resolveEndpoint("UploadQueryFile",{modelId:e.getModel().getId()});return this.context.getServices().getHttpClient().post(r,t.data,{dataType:"form-data"}).then((function(t){return t.query}))},t}(),U=function(){function t(t){this.context=t,this.levels={}}return t.prototype.getAggregateData=function(t,e){var r=this;return new Promise((function(o,n){var i=function(t){var i=r.groupKeyToStr(e),s=t.get(i);s?o(s):n("Can't find data for ".concat(i))},s=r.getLevelDesc(t,!1);s&&s.data?i(s.data):s.receivedCallbacks.push(i)}))},t.prototype.setAggregateData=function(t,e){var r=this.getLevelDesc(t,!0);if(r.data=e,r.receivedCallbacks)for(var o=0,n=r.receivedCallbacks;o<n.length;o++){(0,n[o])(r.data)}r.receivedCallbacks=[]},t.prototype.updateAggregateData=function(t,e,r){var o=this.getLevelDesc(t,!0),n=this.groupKeyToStr(e);o.data.set(n,r)},t.prototype.groupKeyToStr=function(t){return JSON.stringify(t)},t.prototype.getLevelDesc=function(t,e){var r=this.levels[t];return!r&&e&&(r={receivedCallbacks:[],data:new Map},this.levels[t]=r),r},t.prototype.clear=function(){this.levels=[]},t}(),V=function(){function t(t){this.context=t,this.aggrs=null}return t.prototype.getAggrContainer=function(){return this.aggrs},t.prototype.calculate=function(t){console.warn("Grand totals and sub totals aggregation calculation can be used in Enterprise version only"),(t=t||{}).maxLevel=t.maxLevel>=0?t.maxLevel:0,this.aggrs=new U(this.context);var e=this.context.createQuery();e.loadFromData(this.context.getQuery().toJSONData());for(var r=this.context.getQuery().getAggregationSettings(),o=r.getAggregates().map((function(t){return t.colId})),n=e.getColumns().filter((function(t){return o.indexOf(t.id)<0})),i=0;i<n.length;i++)n[i].enabled=!1;r.hasGrandTotals()&&(this.aggrs.setAggregateData(0,new Map),t.resultObtained&&t.resultObtained({},0));for(var s=r.getGroups(),a=1;a<=s.length&&a<=t.maxLevel;a++)this.aggrs.setAggregateData(a,new Map),t.resultObtained&&t.resultObtained({},a);return Promise.resolve()},t.prototype.needRecalculation=function(){return!0},t.prototype.reset=function(){},t}(),W=function(){function t(t){this.context=t,this.modelLoader=null,this.queryStorage=null,this.querySynchronizer=null,this.dataFetcher=null,this.valueListResolver=null,this.queryFileLoader=null,this.aggrCalculator=null,this.httpClient=new o.eN,this.httpClient.defaultHeaders["x-eqjs-version"]="7.2.0",this.modelResolver=function(t){return new w},this.modelStorageResolver=null,this.queryResolver=function(t){return new k(t.getModel())},this.modelLoaderResolver=function(t){return new N(t)},this.queryStorageResolver=function(t){return new P(t)},this.querySynchronizerResolver=function(t){return new B(t)},this.vlrResolver=function(t){return new j(t)},this.dataFetcherResolver=function(t){return new Q(t)},this.queryFileLoaderResolver=function(t){return new G(t)},this.aggrCalculatoResolver=function(t){return new V(t)}}return t.prototype.reset=function(){this.modelStorage=null,this.modelLoader=null,this.queryStorage=null,this.querySynchronizer=null},t.prototype.getHttpClient=function(){return this.httpClient},t.prototype.createDataModel=function(){if(!this.modelResolver)throw"Model resolver is not defined";return this.modelResolver(this.context)},t.prototype.createQuery=function(){if(!this.queryResolver)throw"Query resolver is not defined";return this.queryResolver(this.context)},t.prototype.getModelLoader=function(){if(!this.modelLoader){if(!this.modelLoaderResolver)throw"ModelLoaderResolver is not defined";this.modelLoader=this.modelLoaderResolver(this.context)}return this.modelLoader},t.prototype.getModelStorage=function(){if(!this.modelStorage){if(!this.modelStorageResolver)throw"ModelStorageResolver is not defined";this.modelStorage=this.modelStorageResolver(this.context)}return this.modelStorage},t.prototype.getQueryStorage=function(){if(!this.queryStorage){if(!this.queryStorageResolver)throw"QueryStorageResolver is not defined";this.queryStorage=this.queryStorageResolver(this.context)}return this.queryStorage},t.prototype.getQuerySynchronizer=function(){if(!this.querySynchronizer){if(!this.querySynchronizerResolver)throw"QuerySynchronizerResolver is not defined";this.querySynchronizer=this.querySynchronizerResolver(this.context)}return this.querySynchronizer},t.prototype.getDataFetcher=function(){if(!this.dataFetcher){if(!this.dataFetcherResolver)throw"DataFetcherResolver is not defined";this.dataFetcher=this.dataFetcherResolver(this.context)}return this.dataFetcher},t.prototype.getValueListResolver=function(){if(!this.valueListResolver){if(!this.vlrResolver)throw"Resolver for ValueListResolver is not defined";this.valueListResolver=this.vlrResolver(this.context)}return this.valueListResolver},t.prototype.getQueryFileLoader=function(){if(!this.queryFileLoader){if(!this.queryFileLoaderResolver)throw"Resolver for QueryFileLoader is not defined";this.queryFileLoader=this.queryFileLoaderResolver(this.context)}return this.queryFileLoader},t.prototype.getAggregatesCalculator=function(){if(!this.aggrCalculator){if(!this.aggrCalculatoResolver)throw"Resolver for AggregatesCalculator is not defined";this.aggrCalculator=this.aggrCalculatoResolver(this.context)}return this.aggrCalculator},t.prototype.registerDataModelResolver=function(t){this.modelResolver=t},t.prototype.registerQueryResolver=function(t){this.queryResolver=t},t.prototype.registerModelLoaderResolver=function(t){this.modelLoaderResolver=t},t.prototype.registerModelStorageResolver=function(t){this.modelStorageResolver=t},t.prototype.registerQueryStorageResolver=function(t){this.queryStorageResolver=t},t.prototype.registerDataFetcherResolver=function(t){this.dataFetcherResolver=t},t.prototype.registerQuerySyncronizerResolver=function(t){this.querySynchronizerResolver=t},t.prototype.registerValueListResolver=function(t){this.vlrResolver=t},t.prototype.registerQueryFileLoaderResolver=function(t){this.queryFileLoaderResolver=t},t.prototype.registerAggregatesCalculator=function(t){this.aggrCalculatoResolver=t},t}(),H=function(){function t(t){this.context=t}return t.prototype.loadChunk=function(t){var e=this;return this.dataLoadPromise=new Promise((function(r,n){var i={chunk:t,success:function(n){for(var i=new o.XH({loader:e.context.dataLoader,chunkSize:e.context.resultTable.chunkSize}),s=n.resultSet,a=0,u=s.cols;a<u.length;a++){var l=u[a];i.columns.add(l)}i.setTotal(n.meta.totalRecords);for(var c=0,d=s.rows;c<d.length;c++){var h=d[c];i.addRow(h)}var p=0;n.meta&&n.meta.totalRecords&&(p=n.meta.totalRecords),r({table:i,total:p,hasNext:!t.needTotal||t.offset+t.limit<p})},error:function(t){return n(t)}};e.context.debugMode&&(i.debug="Data Chunk. Offset: ".concat(t.offset)),e.context.fetchDataChunk(i)})),this.dataLoadPromise},t}(),J=__webpack_require__(412);!function(t){t[t.None=0]="None",t[t.Model=1]="Model",t[t.Query=2]="Query",t[t.Result=4]="Result",t[t.Statement=8]="Statement",t[t.QueryStatus=16]="QueryStatus",t[t.All=65535]="All"}(_||(_={})),function(t){t.LoadModel="LoadModel",t.LoadQuery="LoadQuery",t.LoadQueryList="LoadQueryList",t.NewQuery="NewQuery",t.SaveQuery="SaveQuery",t.RemoveQuery="RemoveQuery",t.SyncQuery="SyncQuery",t.FetchData="FetchData",t.GetValueList="GetValueList",t.ExportResult="ExportResult",t.GetQueryFile="GetQueryFile",t.UploadQueryFile="UploadQueryFile"}(O||(O={}));var z,K=function(){function t(t){this.models=[],t&&o.P6.assign(this.models,[],t)}return t.prototype.getModels=function(){var t=this;return new Promise((function(e,r){e(t.models)}))},t}();!function(t){t[t.Error=0]="Error",t[t.Success=1]="Success"}(z||(z={}));var Y=function(){function t(t){this.context=t}return t.prototype.setFormat=function(t,e){this.format=t,this.responseType=e},t.prototype.export=function(t){t=t||{};var e=this.context.getServices().getHttpClient(),r=this.format||"csv",o=t.query||this.context.getQuery(),n=o.getModel().getId(),i={settings:t.settings,chunk:a};void 0!==t.queryId?i.queryId=t.queryId:i.query=o.toJSONData(),t.data&&(i.data=t.data),t.options&&(i.options=t.options);var s=this.context.resolveEndpoint("ExportResult",{modelId:n,format:r}),u=e.post(s,i,{responseType:this.responseType}),l=u.getRequest();return u.then((function(t){var e=new Blob([t]),o=l.getXMLHttpRequest().getResponseHeader("Content-Disposition"),n=o?o.match(/filename="(.*)"/)[1]:"export-data."+r;if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(e,n);else{var i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=window.URL.createObjectURL(e),i.download=n,i.click(),window.URL.revokeObjectURL(i.href),document.body.removeChild(i)}}))},t}(),$=function(){return $=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},$.apply(this,arguments)},X=function(){function t(){var t=this;this.options={},this.servicesInitialized=!1,this.internalListCache={},this.loadModelOnStart=!0,this.loadQueryOnStart=!1,this.useStoredQueryOnFetch=!1,this.debugMode=!1,this._backendInfo={type:"EQN-ANC",subType:"asp-net-core-razor"},this.endpointVarsRegex=/\{.*?\}/g,this.elasticPaging=!1,this._predefinedListRequestHandlers={_DSDE:function(e,r){return r(t.getModel().getAllDateMacros().map((function(t){return{id:"${{"+t+"}}",text:o.ag.getText(t)}}))),!0},_DSTE:function(e,r){return r(t.getModel().getAllTimeMacros().map((function(t){return{id:"${{"+t+"}}",text:o.ag.getText(t)}}))),!0}},this._listRequestHandler=function(e,r){if(null!=e&&e.listName){var n=t.getQuery(),i=o.P6.assign({listName:e.listName},e.editorParams),s={},a=/@{{(.+?)}}/;for(var u in i)if(i[u]){var l=i[u].match(a);if(l){var c=n.getOneValueForAttr(l[1]);c||(c=""),s[u]=i[u].replace(a,c)}}var d={listName:s.listName,editorId:e.editorId,queryParams:s},h=t.getListFromCache(e);if(h&&h.length>0)r(h);else{var p=!1,f=t._predefinedListRequestHandlers[e.editorId];f&&(p=f(e,r)),!p&&t.clientListRequestHandler&&(p=t.clientListRequestHandler(e,r)),p||t.loadValueList({params:d,success:function(o){o&&t.addListToCache(e,o),r(o)},error:function(t){r(null)}})}}},this.baseEndpoint="api/easyquery",this.eqServices=new W(this),this.widgets=new Array,this.eventEmitter=new o.vp(this),this.exporters=new Map,this.endpoints=new Map,this.dataLoader=new H(this),this.resultTable=new o.XH({loader:this.dataLoader,onUpdate:this.onResultTableUpdate.bind(this)}),this.resultTable.id="ResultTable",this.errorHandlerId=this.addEventListener("error",(function(t,e){e.result=z.Error;var r=e.action?e.action+" error":"Error",o=e.text?e.text:"";e.sourceError&&e.sourceError.message!==o&&(o+="\n"+e.sourceError),console.error(r+": "+o)}))}return t.prototype.getServices=function(){return this.eqServices},t.prototype.registerExporter=function(t,e){this.exporters.set(t,e)},t.prototype.registerServerExporter=function(t,e){this.registerExporter(t,(function(r){var o=new Y(r);return o.setFormat(t,e),o}))},t.prototype.getExporter=function(t){var e=this.exporters.get(t);return e?e(this):null},t.prototype.getExportFormats=function(){return Array.from(this.exporters.keys())},t.prototype.addDefaultExporters=function(){this.registerServerExporter("csv",""),this.registerServerExporter("excel-html","")},t.prototype.resolveEndpoint=function(t,e){e=e||{};var r=this.endpoints.get(t);if(!r)throw t+" endpoint is not defined";var o=r.match(this.endpointVarsRegex);if(o)for(var n=0,i=o;n<i.length;n++){var s=i[n],a=s.substring(1,s.length-1),u=e[a];if(!u)if("modelId"==a)u=this.getModel().getId();else{if("queryId"!=a)throw"Parameter [".concat(a,"] is not defined");u=this.getQuery().getId()}r=r.replace(s,u)}return r},t.prototype.setEndpoint=function(t,e){this.endpoints.set(t,e)},t.prototype.setEnpointIfNotExist=function(t,e){this.endpoints.has(t)||this.endpoints.set(t,e)},t.prototype.setDefaultEndpoints=function(t){this.setEnpointIfNotExist("GetModel",e.combinePath(t,"models/{modelId}")),this.setEnpointIfNotExist("GetQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SaveQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SyncQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}/sync")),this.setEnpointIfNotExist("NewQuery",e.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("RemoveQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("GetQueryList",e.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("FetchData",e.combinePath(t,"models/{modelId}/fetch")),this.setEnpointIfNotExist("GetValueList",e.combinePath(t,"models/{modelId}/valuelists/{listId}")),this.setEnpointIfNotExist("ExportResult",e.combinePath(t,"models/{modelId}/export/{format}")),this.setEnpointIfNotExist("GetQueryFile",e.combinePath(t,"models/{modelId}/getqueryfile/{format}")),this.setEnpointIfNotExist("UploadQueryFile",e.combinePath(t,"models/{modelId}/uploadqueryfile"))},t.prototype.initStart=function(){this.servicesInitialized=!0},t.prototype.init=function(t){var e=this;(this.servicesInitialized||this.initStart(),t=t||{},this.setOptions(t),void 0!==t.debugMode&&(this.debugMode=t.debugMode),void 0!==t.chunkSize&&(this.resultTable.chunkSize=t.chunkSize),void 0!==t.elasticPaging&&(this.elasticPaging=t.elasticPaging),t.listCache&&this.setExternalListCache(t.listCache),t.locale&&o.ag.setCurrentLocale(t.locale),t.localeSettings&&o.ag.updateLocaleSettings(t.localeSettings),t.endpoint&&(this.baseEndpoint=t.endpoint,console.warn("The `endpoint` option is deprecated.\nPlease use `context.useEndpoint(endpointURL)` function instead.")),this.setDefaultEndpoints(this.baseEndpoint),t.modelStorageResolver)&&this.getServices().registerModelStorageResolver(t.modelStorageResolver);if(this.loadQueryOnStart=!1,t.loadQueryOnStart&&(this.loadQueryOnStart=t.loadQueryOnStart),this.loadModelOnStart=!0,void 0!==t.loadModelOnStart&&(this.loadModelOnStart=t.loadModelOnStart),t.handlers&&(t.handlers.onInit&&this.addEventListener("ready",t.handlers.onInit),t.handlers.afterLoadModel&&this.addEventListener("loadModel",t.handlers.afterLoadModel),t.handlers.afterLoadQuery&&this.addEventListener("loadQuery",t.handlers.afterLoadQuery),t.handlers.afterSyncQuery&&this.addEventListener("syncQuery",t.handlers.afterSyncQuery),t.handlers.afterFetchData&&this.addEventListener("fetchData",t.handlers.afterFetchData),t.handlers.afterExportResult&&this.addEventListener("exportResult",t.handlers.afterExportResult),t.handlers.onProcessStart&&this.addEventListener("processStart",t.handlers.onProcessStart),t.handlers.onProcessEnd&&this.addEventListener("processEnd",t.handlers.onProcessEnd),t.handlers.onError&&(this.removeEventListener("error",this.errorHandlerId),this.addEventListener("error",t.handlers.onError)),t.handlers.onListRequest&&(this.clientListRequestHandler=t.handlers.onListRequest),t.handlers.beforeLoadModel&&(this.beforeLoadModel=t.handlers.beforeLoadModel),t.handlers.beforeLoadQuery&&(this.beforeLoadQuery=t.handlers.beforeLoadQuery),t.handlers.beforeSyncQuery&&(this.beforeSyncQuery=t.handlers.beforeSyncQuery),t.handlers.beforeFetchData&&(this.beforeFetchData=t.handlers.beforeFetchData),t.handlers.beforeExportResult&&(this.beforeExportResult=t.handlers.beforeExportResult)),this.initialQuery=t.initialQuery,this.defaultQueryId=t.defaultQueryId||"",this.defaultModelId=t.defaultModelId||"__default",this.eqServices.getModelLoader().init(t),this.eqServices.getQueryStorage().init(t),!1!==t.useDefaultExporters&&this.addDefaultExporters(),t.serverExporters){this.exporters.clear();for(var r=0,n=t.serverExporters;r<n.length;r++){var i=n[r],s="csv"==i||"excel-html"==i?"":"arraybuffer";this.registerServerExporter(i,s)}}var a=this.getQuery();t.defaultQueryId&&a.setId(t.defaultQueryId),this.widgets.forEach((function(r){var o={};t.widgets&&t.widgets[r.getWidgetType()]&&(o=t.widgets[r.getWidgetType()]),r.init(e,o)})),this.loadModelOnStart?this.loadDefaultModel():this.fireEvent("ready")},t.prototype.setOptions=function(t){o.P6.assignDeep(this.options,t)},Object.defineProperty(t.prototype,"backendInfo",{get:function(){return this._backendInfo},enumerable:!1,configurable:!0}),t.prototype.useEndpoint=function(t){return this.baseEndpoint=t,this},t.prototype.useBackend=function(t){if(t.type&&(this._backendInfo.type=t.type),t.subType)this._backendInfo.subType=t.subType;else switch(this._backendInfo.type){case"EQN-ANC":this._backendInfo.subType="asp-net-core-razor";break;case"EQN-ASP":this._backendInfo.subType="asp-net-4-mvc";break;default:this._backendInfo.subType="other"}return this},t.prototype.addWidget=function(t){this.widgets.push(t)},t.prototype.getAllWidgetsByType=function(t){return this.widgets.filter((function(e){return e.getWidgetType()===t}))},t.prototype.getWidgetByType=function(t){var e=this.getAllWidgetsByType(t);return e.length>0?e[0]:null},t.prototype.refreshWidgets=function(t){void 0===t&&(t=_.All),this.widgets.forEach((function(e){e.belongsToGroup(t)&&e.refresh()}))},t.prototype.addQueryChangedCallback=function(t){this.getQuery().addChangedCallback(t)},t.prototype.removeQueryChangedCallback=function(t){this.getQuery().removeChangedCallback(t)},t.prototype.createQuery=function(){return this.eqServices.createQuery()},t.prototype.getQuery=function(){if(!this.query){if(!this.servicesInitialized)throw new Error("Can't create query until the context is initialized");this.query=this.createQuery()}return this.query},t.prototype.getModel=function(){return this.dataModel||(this.dataModel=this.eqServices.createDataModel()),this.dataModel},t.prototype.loadModelFromData=function(t){this.getQuery().loadModelData(t),this.dataModel=this.getQuery().getModel()},t.prototype.setDefaultModelId=function(t){this.defaultModelId=t},t.prototype.startProcess=function(t,e){this.eventEmitter.fire("processStart",t),this.widgets.forEach((function(t){t.belongsToGroup(e)&&t.onProcessStart()}))},t.prototype.endProcess=function(t,e){this.eventEmitter.fire("processEnd",t),t.result===z.Error&&this.throwError(t),this.widgets.forEach((function(t){t.belongsToGroup(e)&&t.onProcessEnd()}))},t.prototype.throwError=function(t){t.result=z.Error,this.eventEmitter.fire("error",t)},t.prototype.loadDefaultModel=function(){var t=this;this.loadModel({modelId:this.defaultModelId,silent:!0,success:function(){t.refreshWidgets(_.Model);var e=t.getQuery();t.fireEvent("initialModelLoad"),t.initialQuery&&e.loadFromData(t.initialQuery,{changeStatus:!1}),t.loadQueryOnStart?t.loadQuery({queryId:t.defaultQueryId,modelId:t.defaultModelId,success:function(){t.refreshWidgets(_.Query),t.fireEvent("ready")}}):(t.refreshWidgets(_.Query),t.fireEvent("ready"))}})},t.prototype.clearQuery=function(){var t=this.getQuery();t.clear(),t.fireChangedEvent({part:x.All})},t.prototype.clearResult=function(){this.resultTable.clear(),this.resultStatement=null,this.resultContent=null},t.prototype.setExternalListCache=function(t){this.externalListCache=t},t.prototype.getListFromCache=function(t){var e=this.getListCacheKey(t);return this.externalListCache?this.externalListCache.get(e):this.internalListCache[e]},t.prototype.getListCacheKey=function(t){var e="SQL"==t.listName?"SQL_"+t.editorId:t.listName;return t.queryParams&&(e+="_"+Object.keys(t.queryParams).filter((function(t){return"listName"!=t})).map((function(e){return t.queryParams[e]})).join("_")),e},t.prototype.addListToCache=function(t,e){var r=this.getListCacheKey(t);this.externalListCache?this.externalListCache.set(r,e):this.internalListCache[r]=e},t.prototype.resetListCache=function(){this.externalListCache?this.externalListCache.clear():this.internalListCache={}},t.prototype.getListRequestHandler=function(){return this._listRequestHandler},t.prototype.addLocale=function(t,e){o.ag.addLocale(t,e)},t.prototype.addEventListener=function(t,e){var r=this;return this.eventEmitter.subscribe(t,(function(t){return e(r,t.data)}))},t.prototype.removeEventListener=function(t,e){this.eventEmitter.unsubscribe(t,e)},t.prototype.fireEvent=function(t,e){this.eventEmitter.fire(t,e)},t.prototype.getBaseEndpoint=function(){return this.baseEndpoint},t.prototype.loadValueList=function(t){var e=this;t=t||{},this.startProcess({action:O.GetValueList,text:"Loading values"},_.Result),this.eqServices.getValueListResolver().loadValueList(t).then((function(r){e.endProcess({result:z.Success,action:O.GetValueList,text:"Values loaded"},_.Result),t.success&&t.success(r)})).catch((function(r){var o=t&&t.params?t.params.editorId:"undefined",n="Can't load the value list for editor ".concat(o,".\n ").concat(r.message);e.endProcess({result:z.Error,action:O.GetValueList,text:n,sourceError:r},_.Result),t.error&&t.error(n,"GetValueList")}))},t.prototype.loadModel=function(t){var e=this;this.beforeLoadModel&&this.beforeLoadModel(this,t);var r=t.modelId||"__default",o=t.silent||!1;return this.startProcess({action:O.LoadModel,text:"Loading model: "+r},_.Model),this.eqServices.getModelLoader().startModelLoading(t).then((function(n){return n?(e.loadModelFromData(n),e.dataModel.isEmpty()&&console.warn("Empty model has been loaded. Model ID: ".concat(e.dataModel.getId()))):console.warn("Model has not been changed."),e.fireEvent("loadModel"),e.endProcess({result:z.Success,action:O.LoadModel,text:"Model loaded: "+r},_.Model),o||(e.clearQuery(),e.clearResult(),e.refreshWidgets()),t.success&&t.success(e.getModel()),e.getModel()})).catch((function(o){var n="Can't load model ".concat(r,".\n ").concat(o.message);return e.endProcess({result:z.Error,action:O.LoadModel,text:n,sourceError:o},_.Model),t.error&&t.error(n,"LoadModel"),e.getModel()}))},t.prototype.callWhenModelLoaded=function(t){this.eqServices.getModelLoader().getModelPromise().then((function(){t()}))},t.prototype.loadQuery=function(t){var e=this;t=t||{};var r=this.eqServices.getModelLoader();this.clearResult(),r.getModelPromise().then((function(){var r=(t=t||{}).queryId,o=t.silent||!1;e.beforeLoadQuery&&e.beforeLoadQuery(e,t),e.startProcess({action:O.LoadQuery,text:"Query loading: "+r},_.Query),e.eqServices.getQueryStorage().loadQuery(t).then((function(n){n&&e.query.loadFromData(n,{validate:!1}),e.limitCustomSqlColumns(),e.fireEvent("loadQuery"),e.endProcess({result:z.Success,action:O.LoadQuery,text:"Query loaded: "+r},_.Query),e.query.resetModified(),o||(e.query.fireChangedEvent({part:x.Properties,wasModified:e.query.isModified()}),e.refreshWidgets()),t.success&&t.success(e.query)})).catch((function(r){var o=e.getQuery();r.message="Can't load query ["+o.getId()+"]\n"+(r.message||""),t.error&&t.error(r.message,O.LoadQuery),e.endProcess({result:z.Error,action:O.LoadQuery,text:r.message,sourceError:r},_.Query)}))})).catch((function(t){console.error(t)}))},t.prototype.loadQueryList=function(t){var e=this;this.eqServices.getModelLoader().getModelPromise().then((function(){e.startQueryListLoading(t)})).catch((function(t){var r="Can't load the list of available queries.\n ".concat(t.message);e.throwError({action:O.LoadQueryList,text:r,sourceError:t})}))},t.prototype.startQueryListLoading=function(t){var e=this;t=t||{},this.eqServices.getQueryStorage().getQueryList(t).then((function(e){t.success&&t.success(e)})).catch((function(r){var o="Can't load the list of available queries.\n ".concat(r.message);t.error?t.error(o,"LoadQueryList"):e.throwError({action:O.LoadQueryList,text:o,sourceError:r})}))},t.prototype.newQuery=function(t){var e=this,r=void 0===(t=t||{}).clearQuery||t.clearQuery;this.query.reset(r),t.queryId&&this.query.setId(t.queryId),t.name&&this.query.setName(t.name),t.description&&this.query.setDescription(t.description);var o=t.silent||!1,n=!0;void 0!==t.useStorage&&(n=t.useStorage);var i=function(){var t=e.getQuery();t.isNewbie=!0,o||t.fireChangedEvent({part:x.All,wasModified:t.isModified()})};n?(this.startProcess({action:O.NewQuery,text:"New query creation..."},_.Query),this.eqServices.getQueryStorage().newQuery(t).then((function(r){r&&e.query.loadFromData(r),e.endProcess({result:z.Success,action:O.NewQuery,text:"A new query has been created"},_.Query),i(),t.success&&t.success()})).catch((function(r){var o="Can't create a new query.\n".concat(r.message);e.endProcess({result:z.Error,action:O.NewQuery,text:o,sourceError:r},_.Query),t.error&&t.error(o,"NewQuery")}))):i();return this.query},t.prototype.saveQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:O.SaveQuery,text:"Query saving: "+r.getId()},_.Query),this.eqServices.getQueryStorage().saveQuery(t).then((function(o){e.endProcess({action:O.SaveQuery,result:z.Success,text:"Query saved: "+r.getId()},_.Query),o&&r.loadFromData(o),r.resetModified(),r.isNewbie=!1,t.success&&t.success()})).catch((function(o){var n="Can't save query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({action:O.SaveQuery,result:z.Error,text:n,sourceError:o},_.Query),t.error&&t.error(n,O.SaveQuery)}))},t.prototype.removeQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:O.RemoveQuery,text:"Query deleting: "+r.getId()},_.Query),this.eqServices.getQueryStorage().removeQuery(t).then((function(){r.reset(),e.endProcess({action:O.RemoveQuery,result:z.Success,text:"Query deleted: "+r.getId()},_.Query),t.success&&t.success()})).catch((function(o){var n="Can't remove query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({action:O.RemoveQuery,result:z.Error,text:n,sourceError:o},_.Query),t.error&&t.error(n,"RemoveQuery")}))},t.prototype.syncQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.beforeSyncQuery&&this.beforeSyncQuery(this,t),this.startProcess({action:O.SyncQuery,text:"Query syncing: "+r.getId()},_.Query),this.eqServices.getQuerySynchronizer().syncQuery(t).then((function(o){if(e.resultStatement=o&&o.statement?o.statement:"",e.fireEvent("syncQuery"),e.refreshWidgets(_.Statement),e.endProcess({result:z.Success,action:O.SyncQuery,text:"Query synced: "+r.getId()},_.Query),o){if(o.querySaved){var n=o.query;n&&(r.setId(n.id),r.setName(n.name),r.setDescription(n.desc),r.extraData=n.extraData),r.resetModified(),e.refreshWidgets(_.QueryStatus)}t.success&&t.success(o)}})).catch((function(o){var n="Can't synchronize query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({result:z.Error,action:O.SyncQuery,text:n,sourceError:o},_.Query),t.error&&t.error(n,"SyncQuery")}))},t.prototype.fetchData=function(t){var e=this,r=void 0!==(t=t||{}).elasticPaging?t.elasticPaging:this.elasticPaging;this.resultTable.elasticChunks=r,t.chunk=t.chunk||{offset:0,limit:this.resultTable.chunkSize,needTotal:!r},this.debugMode&&(t.debug="Fetching the result set. Initial chunk"),this.query.tryValidate({checkExpressions:!0})&&(t.groupFetchSuccess&&(this.afterGroupFetch=t.groupFetchSuccess),this.resultTable.elasticChunks&&t.chunk.limit++,this.fetchDataChunk($($({},t),{success:function(r){if(r.statement&&(e.resultStatement=r.statement,e.refreshWidgets(_.Statement)),e.getServices().getAggregatesCalculator().reset(),e.resultContent=r,r.resultSet){e.resultTable.clear(),e.resultTable.id=e.query.getId();for(var o=r.resultSet,n=0,i=o.cols;n<i.length;n++){var s=i[n];e.resultTable.columns.add(s)}r.meta&&void 0!==r.meta.totalRecords&&e.resultTable.setTotal(r.meta.totalRecords);var a=o.rows.length;e.resultTable.elasticChunks&&a===t.chunk.limit&&o.rows.splice(o.rows.length-1,1);for(var u=0,l=o.rows;u<l.length;u++){var c=l[u];e.resultTable.addRow(c)}e.resultTable.elasticChunks&&(e.resultTable.total=a<t.chunk.limit?o.rows.length:0),e.resultTable.fireUpdated()}t.success&&t.success(r)}})))},t.prototype.getQueryFile=function(t){var e=this,r=this.getQuery();this.startProcess({action:O.GetQueryFile,text:"Getting query file: "+r.getId()},_.Query),this.getServices().getQueryFileLoader().getQueryFile(t).then((function(){e.endProcess({result:z.Success,action:O.GetQueryFile,text:"Getting query file: "+r.getId()},_.Query),t.success&&t.success()})).catch((function(o){var n="Can't get file for query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({result:z.Error,action:O.GetQueryFile,text:n,sourceError:o},_.Query),t.error&&t.error(n,"GetQueryFile")}))},t.prototype.uploadQueryFile=function(t){var e=this,r=this.getQuery();this.startProcess({action:O.UploadQueryFile,text:"Uploading query file: "+r.getId()},_.Query),this.getServices().getQueryFileLoader().uploadQueryFile(t).then((function(o){r.loadFromData(o),e.fireEvent("loadQuery"),e.refreshWidgets(),e.endProcess({result:z.Success,action:O.UploadQueryFile,text:"Uploading query file: "+r.getId()},_.Query),t.success&&t.success()})).catch((function(o){var n="Can't upload a file for query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({result:z.Error,action:O.UploadQueryFile,text:n,sourceError:o},_.Query),t.error&&t.error(n,"UploadQueryFile")}))},t.prototype.fetchDataChunk=function(t){var e=this,r=this.getQuery().getId(),o=t||{};this.useStoredQueryOnFetch&&(o.queryId=this.query.getId()),this.beforeFetchData&&this.beforeFetchData(this,o),this.startProcess({action:O.FetchData,text:"Fetching data for the query: "+r},_.Result),this.eqServices.getDataFetcher().fetchData(o).then((function(t){t.statement&&(e.resultStatement=t.statement),e.resultContent=t,o.success&&o.success(t),e.fireEvent("fetchData"),e.endProcess({result:z.Success,action:O.FetchData,text:"Data fetching is finished for the query: "+r},_.Result)})).catch((function(t){var n="Data fetching error for the query ".concat(r,". \n").concat(t.message);e.endProcess({result:z.Error,action:O.FetchData,text:n,sourceError:t},_.Result),o.error&&o.error(n,O.FetchData)}))},t.prototype.onResultTableUpdate=function(){var t=this,e=this.query.getAggregationSettings(),r=this.getServices().getAggregatesCalculator();e.needAggrCalculation()&&r.needRecalculation()&&r.calculate({maxLevel:e.getGroups().length+1,resultObtained:function(e,r){t.afterGroupFetch&&t.afterGroupFetch(e)},errorOccurred:function(e){var r="Data fetching error on group level ".concat(e.level," query. \n").concat(e.message);t.throwError({action:O.FetchData,text:r,sourceError:e})}})},t.prototype.fetchDrillDownData=function(t){var e=this;(t=t||{}).chunk=t.chunk||{offset:0,limit:this.resultTable.chunkSize,needTotal:!0};var r=t.query.getId();this.startProcess({action:O.FetchData,text:"DrillDown executing: "+r},_.Result),this.eqServices.getDataFetcher().fetchData(t).then((function(o){e.endProcess({result:z.Success,action:O.FetchData,text:"DrillDown execution error: "+r},_.Result),t.success&&t.success(o)})).catch((function(o){var n="Drill-down data fetching error for query ".concat(r,". \n").concat(o.message);e.endProcess({result:z.Error,action:O.FetchData,text:n},_.Result),t.error?t.error(n,"DrillDown"):e.throwError({action:O.FetchData,text:n})}))},t.prototype.exportResult=function(t){var e=this;(t=t||{}).chunk=t.chunk||a,this.beforeExportResult&&this.beforeExportResult(this,t);var r=t.format;if(r){var n=this.getExporter(r);if(n){var i=this.getQuery().getId();this.useStoredQueryOnFetch&&(t.queryId=i),this.startProcess({action:O.ExportResult,text:"Exporting result for query: "+i},_.Result);var s=o.ag.getLocaleSettings();t.settings=s;var u=this.query.getAggregationSettings();u.hasAggregates()&&(u.hasGrandTotals()||u.hasGroups())&&(t.aggregates=u.saveToData()),n.export(t).then((function(r){e.fireEvent("exportResult"),e.endProcess({result:z.Success,action:O.ExportResult,text:"The result set for query [".concat(i,"] has been successfully exported")},_.Result),t.success&&t.success()})).catch((function(r){var o="Error on exporting data for query ".concat(i,". \n").concat(r.message);e.endProcess({result:z.Error,action:O.ExportResult,text:o,sourceError:r},_.Result),t.error&&t.error(o,"ExportResult")}))}}},t.prototype.limitCustomSqlColumns=function(){this.options.allowCustomExpressions||this.query.getColumns().forEach((function(t){t.expr.tag===d.CustomSql&&(t.enabled=!1)}))},t}(),Z=function(){function t(t){this.slot=t,this._id=o.P6.generateId(this.getWidgetType())}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),t.prototype.init=function(t,e){this.context=t},t.prototype.getContext=function(){return this.context},t.prototype.refresh=function(){this.refreshCore()},t.prototype.refreshCore=function(){},t.prototype.onProcessStart=function(){this.onProcessStartCore()},t.prototype.onProcessStartCore=function(){},t.prototype.onProcessEnd=function(){this.onProcessEndCore()},t.prototype.onProcessEndCore=function(){},t.prototype.belongsToGroup=function(t){return void 0===t||null==t||0!=(t&this.group)},t.prototype.destroy=function(){this.destroyCore()},t.prototype.destroyCore=function(){},t}(),tt=new(function(){function t(t,e,r){this.major=t,this.minor=e,this.update=r}return t.prototype.toString=function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.update)},t}())(6,2,0);o.ag.updateDefaultTexts({NewQueryName:"[New query]",Today:"Today",Yesterday:"Yesterday",Tomorrow:"Tomorrow",FirstDayOfMonth:"First day of the month",LastDayOfMonth:"Last day of the month",FirstDayOfWeek:"First day of the week",FirstDayOfYear:"First day of the year",FirstDayOfNextWeek:"First day of the next week",FirstDayOfNextMonth:"First day of the next month",FirstDayOfNextYear:"First day of the next year",Now:"Now",HourStart:"This hour start",Midnight:"Midnight",Noon:"Noon",Entities:{},Attributes:{},Operators:{},AggregateFunctions:{}})})(),__webpack_exports__})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("easyqueryCore",[],e):"object"==typeof exports?exports.easyqueryCore=e():t.easyqueryCore=e()}(self,(()=>(()=>{"use strict";var __webpack_modules__={412:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{e:()=>GoogleDataConverter});var _easydata_core__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(907),GoogleDataConverter=function(){function GoogleDataConverter(t){t||(t={cols:[],rows:[]}),"string"==typeof t?this.loadFromJSON(t):this.tableObj=t}return GoogleDataConverter.prototype.loadFromJSON=function(t){this.tableObj=JSON.parse(t)},GoogleDataConverter.prototype.toJSON=function(){return JSON.stringify(this.tableObj)},GoogleDataConverter.prototype.getObject=function(){return this.tableObj},GoogleDataConverter.prototype.isEmpty=function(){return 0==this.getNumberOfColumns()||0==this.getNumberOfRows()},GoogleDataConverter.prototype.getNumberOfColumns=function(){return this.tableObj.cols.length},GoogleDataConverter.prototype.getColumnObject=function(t){return t<this.tableObj.cols.length?this.tableObj.cols[t]:null},GoogleDataConverter.prototype.getColumnId=function(t){var e=this.getColumnObject(t);return e?e.id:null},GoogleDataConverter.prototype.getColumnLabel=function(t){var e=this.getColumnObject(t);return e?e.label:null},GoogleDataConverter.prototype.getColumnType=function(t){var e=this.getColumnObject(t);return e?e.type:null},GoogleDataConverter.prototype.getColumnProperties=function(t){var e=this.getColumnObject(t);return e?e.p:null},GoogleDataConverter.prototype.getNumberOfRows=function(){return this.tableObj.rows.length},GoogleDataConverter.prototype.convertValue=function(value,colIndex){var colType=this.googleDataTypeToDataType(this.getColumnType(colIndex));return[_easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Date,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.DateTime,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Time].includes(colType)?eval("new ".concat(value)):value},GoogleDataConverter.prototype.getValue=function(t,e){var r=t<this.tableObj.rows.length?this.tableObj.rows[t]:null;if(r){var o=e<this.tableObj.cols.length?r.c[e]:null;if(o)return this.convertValue(o.v,e)}return null},GoogleDataConverter.prototype.getRow=function(t){var e=this;return(t<this.tableObj.rows.length?this.tableObj.rows[t]:null).c.map((function(t,r){return e.convertValue(t.v,r)}),this)},GoogleDataConverter.prototype.convertTo=function(t){for(var e=this.getNumberOfColumns(),r=0;r<e;r++)t.columns.add({id:this.getColumnId(r),label:this.getColumnLabel(r),type:this.googleDataTypeToDataType(this.getColumnType(r))});var o=this.getNumberOfRows();for(r=0;r<o;r++)t.addRow(this.getRow(r))},GoogleDataConverter.prototype.googleDataTypeToDataType=function(t){switch(t){case"string":default:return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.String;case"number":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Float;case"boolean":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Bool;case"date":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Date;case"datetime":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.DateTime;case"timeofday":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.g.Time}},GoogleDataConverter}()},907:(t,e,r)=>{var o,n;r.d(e,{$h:()=>T,g:()=>o,XH:()=>A,mb:()=>s,vp:()=>O,eN:()=>m,U4:()=>E,qR:()=>v,uF:()=>x,S$:()=>b,ag:()=>a,P6:()=>u}),function(t){t[t.Unknown=0]="Unknown",t[t.String=1]="String",t[t.Byte=2]="Byte",t[t.Word=3]="Word",t[t.Int32=4]="Int32",t[t.Int64=5]="Int64",t[t.Bool=6]="Bool",t[t.Float=7]="Float",t[t.Currency=8]="Currency",t[t.BCD=9]="BCD",t[t.Date=10]="Date",t[t.Time=11]="Time",t[t.DateTime=12]="DateTime",t[t.Autoinc=13]="Autoinc",t[t.Memo=14]="Memo",t[t.Blob=15]="Blob",t[t.FixedChar=16]="FixedChar",t[t.Guid=17]="Guid",t[t.Geometry=18]="Geometry",t[t.Geography=19]="Geography"}(o||(o={})),function(t){t[t.Data=0]="Data",t[t.Virtual=1]="Virtual",t[t.Lookup=2]="Lookup"}(n||(n={}));var i,s={Unknown:"Unknown",Edit:"EDIT",DateTime:"DATETIME",List:"LIST",CustomList:"CUSTOMLIST",File:"FILE"};!function(t){t.Trace="TRACE",t.Options="OPTIONS",t.Get="GET",t.Put="PUT",t.Post="POST",t.Delete="DELETE"}(i||(i={}));var a,u,l=function(){function t(t,e){this.xhr=t,this.method=e.method,this.url=e.url,this.headers=e.headers,this.queryParams=e.queryParams,this.data=e.data}return t.prototype.setHeader=function(t,e){this.headers[t]=e},t.prototype.setQueryParam=function(t,e){this.queryParams[t]=e},t.prototype.getXMLHttpRequest=function(){return this.xhr},t.prototype.getResponseHeaders=function(){if(this.xhr.readyState==this.xhr.HEADERS_RECEIVED){for(var t={},e=0,r=this.xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);e<r.length;e++){var o=r[e].split(": "),n=o.shift(),i=o.join(": ");t[n]=i}return t}return{}},t.prototype.open=function(){var t=this;if(this.xhr.readyState===this.xhr.UNSENT){var e=this.url;for(var r in this.queryParams&&Object.keys(this.queryParams).length>0&&(e+=encodeURI("?"+Object.keys(this.queryParams).map((function(e){return e+"="+t.queryParams[e]})).join("&"))),this.xhr.open(this.method,e,!0),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.headers)this.xhr.setRequestHeader(r,this.headers[r])}},t.prototype.abort=function(){this.xhr.abort()},t}();function c(t,e){for(var r="",o=0;o<e;o++)r+=t;return r}!function(t){var e,r={shortDateFormat:"MM/dd/yyyy",longDateFormat:"dd MMM, yyyy",editDateFormat:"MM/dd/yyyy",shortTimeFormat:"HH:mm",editTimeFormat:"HH:mm",longTimeFormat:"HH:mm:ss",shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],shortWeekDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longWeekDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],decimalSeparator:".",currency:"USD"},n={localeId:"en-US",englishName:"English",displayName:"English",texts:{ButtonOK:"OK",ButtonCancel:"Cancel",Yes:"Yes",No:"No",True:"True",False:"False"},settings:r},i={"en-US":n},s=[];function a(t){for(var e=0,r=s;e<r.length;e++){(0,r[e])(t)}}function l(){return e.localeId}function c(t){var r=i[t];r?u.assignDeep(e,r):(e.englishName=t,e.displayName=t,e.texts=u.assignDeep({},n.texts)),e.localeId=t}function d(){return e.settings}function h(t){e.settings||(e.settings=u.assignDeep({},r)),e.settings=u.assignDeep(e.settings,t)}function p(t,r){a(r);var o=e;t&&(r.localeId||(r.localeId=t),(o=i[t])||(o=u.assignDeep({},n),i[t]=o)),u.assignDeep(o,r)}function f(){var t,r,o,n,i,s,a="object"==typeof navigator?navigator.language:void 0;t=a,r=new Date(2020,5,7,19,34,56,88),o=r.toLocaleDateString(t,{year:"numeric",month:"numeric",day:"numeric"}),n=r.toLocaleTimeString(t,{hour:"numeric",minute:"numeric",second:"numeric"}),i=o.replace("07","dd").replace("7","d").replace("06","MM").replace("6","M").replace("2020","yyyy").replace("20","yy"),s=n.replace("19","HH").replace("07","hh").replace("7","h").replace("34","mm").replace("56","ss").replace("PM","tt"),e.settings||(e.settings={}),h({shortDateFormat:i,shortTimeFormat:s})}function g(t){var e,r=d();switch(t){case o.Date:e=r.shortDateFormat;break;case o.Time:e=r.shortTimeFormat;break;default:e=r.shortDateFormat+" "+r.shortTimeFormat}return e}function y(t){var e,r=d();switch(t){case o.Date:e=r.longDateFormat;break;case o.Time:e=r.longTimeFormat;break;default:e=r.longDateFormat+" "+r.longTimeFormat}return e}t.addMapper=function(t){s.push(t)},t.getLocales=function(){var t=[];for(var e in i)t.push({locale:e,englishName:i[e].englishName,displayName:i[e].displayName});return t.sort((function(t,e){return t.englishName>e.englishName?1:t.englishName===e.englishName?0:-1}))},t.getCurrentLocale=l,t.setLocale=function(t){console.warn("This method is deprecated. Use setCurrentLocale instead"),c(t)},t.setCurrentLocale=c,t.getText=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var o=e.texts,n="";if(t&&t.length)for(var i=t.length,s=0;s<i&&"object"==typeof(n=o[t[s]]);s++)o=n;return n},t.getLocaleSettings=d,t.getOneLocaleSetting=function(t){return e.settings[t]},t.getShortMonthName=function(t){var e=d();if(t>0&&t<13)return e.shortMonthNames[t-1];throw"Wrong month number: "+t},t.getLongMonthName=function(t){var e=d();if(t>0&&t<13)return e.longMonthNames[t-1];throw"Wrong month number: "+t},t.getShortWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.shortWeekDayNames.length>=t?e.shortWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.getLongWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.longWeekDayNames.length>=t?e.longWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.updateLocaleSettings=h,t.updateLocaleTexts=function(t){"object"==typeof t?(a({localeId:e.localeId,texts:t}),u.assignDeep(e.texts,t)):console.error("Wrong parameter type in updateLocaleTexts function call.The first parameter (localeId) is not necessary. Use updateLocaleTexts(texts) instead")},t.updateDefaultTexts=function(t){for(var r in i){var o=i[r];o.texts=u.assignDeep({},t,o.texts)}e.texts=u.assignDeep({},t,e.texts)},t.updateLocaleInfo=p,t.addLocale=function(t,e){p(t,e)},t.resetLocales=function(){e||(e=u.assignDeep({},n),f())},t.dateTimeToStr=function(t,e,r){return r?"d"==r?r=g(o.Date):"D"==r?r=y(o.Date):"f"==r?r=g(o.DateTime):"F"==r&&(r=y(o.DateTime)):r=g(e),u.dateTimeToStr(t,r)},t.numberToStr=function(e,r){if(r&&r.length>0){var o=r.charAt(0).toUpperCase();if("S"===o)return function(e,r){if(!m[r]){var o=r.split("|").filter((function(t){return t.length>0})).map((function(t){return t.split("=")}));if(m[r]={},o.length>0)if(o[0].length>1)for(var n=0,i=o;n<i.length;n++){var s=i[n];m[r][Number.parseInt(s[1])]=s[0]}else o.forEach((function(t,e){m[r][e]=t[0]}))}var a=m[r];if(void 0!==a[e]){s=a[e];return t.getText(s)||s}return e.toString()}(e,r.slice(1));if(["D","F","C"].indexOf(o)>=0){var n=l();return e.toLocaleString(n,function(t){var e=d(),r=t[0].toUpperCase(),o=t.length>1?Number.parseInt(t.slice(1)):"D"==r?1:2;switch(r){case"D":return{style:"decimal",useGrouping:!1,minimumIntegerDigits:o};case"C":return{style:"currency",currency:e.currency,minimumFractionDigits:o};default:return{style:"decimal",minimumFractionDigits:o,maximumFractionDigits:o}}}(r))}return function(t,e){for(var r=t.toString(),o="",n=r.length-1,i=e.length-1;i>=0;i--){var s=e.charAt(i);"#"===s||"0"===s?n>=0?(o+=r.charAt(n),n--):"0"===s&&(o+=0):o+=s}return o.split("").reverse().join("")}(Math.trunc(e),r)}var i=d();return u.numberToStr(e,i.decimalSeparator)},t.booleanToStr=function(e,r){if(r&&r.length>0&&"S"===r.charAt(0).toUpperCase()){var o=r.slice(1).split("|");if(o.length>1){var n=o[e?1:0];return t.getText(n)||n}}return"".concat(e)};var m={}}(a||(a={})),function(t){t.getAllDataTypes=function(){return Object.values(o).filter((function(t){return"number"==typeof t}))},t.getDateDataTypes=function(){return[o.Time,o.Date,o.DateTime]},t.getStringDataTypes=function(){return[o.String,o.Memo,o.FixedChar]};var e=[o.Byte,o.Word,o.Int32,o.Int64,o.Float,o.Currency,o.Autoinc];t.getNumericDataTypes=function(){return e};var r=[o.Byte,o.Word,o.Int32,o.Int64,o.Autoinc];function n(t,e,r){e||(e={});for(var o=0,s=r;o<s.length;o++){var a=s[o];if(a)for(var u in a)if(a.hasOwnProperty(u)){var l=a[u];null!==l&&"object"==typeof l?t.has(l)?e[u]=t.get(l):Array.isArray(l)?(e[u]=i(l),t.set(l,e[u])):(void 0!==e[u]&&null!=e[u]||(e[u]=Object.create(Object.getPrototypeOf(l))),t.set(l,e[u]),n(t,e[u],[l])):e[u]=l}}return e}function i(t){for(var e=[],r=0,o=t;r<o.length;r++){var n=o[r];e.push(n)}return e}t.assign=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var o=0;o<e.length;o++){var n=e[o];if(n)for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])}return t},t.assignDeep=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return n(new WeakMap,t,e)},t.getIfDefined=function(t,e){return void 0!==t?t:e},t.IsDefinedAndNotNull=function(t){return null!=t},t.copyArrayTo=function(t,e){for(var r=t.length,o=e.length,n=0;n<r&&n<o;n++)e[n]=t[n]},t.createArrayFrom=i,t.findItemById=function(t,e){for(var r=t.length,o=0;o<r;o++)if(t[o].id===e)return t[o];return null},t.findItemIndexById=function(t,e){for(var r=t.length,o=0;o<r;o++)if(t[o].id===e)return o;return-1},t.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=t.length,o=0;o<r;o++)if(e==t[o])return o;return-1},t.moveArrayItem=function(t,e,r){if(e>=t.length)throw"Index out of bounds: "+e;r>=t.length&&(r=t.length-1);var o=t.splice(e,1)[0];t.splice(r,0,o)},t.removeArrayItem=function(t,e){var r=t.indexOf(e);if(-1!=r)return t.splice(r,1)[0]},t.insertArrayItem=function(t,e,r){t.splice(e,0,r)},t.fillArray=function(t,e,r,o){void 0===r&&(r=0);for(var n=t.length>>>0,i=r>>0,s=i<0?Math.max(n+i,0):Math.min(i,n),a=void 0===o?n:o>>0,u=a<0?Math.max(n+a,0):Math.min(a,n);s<u;)t[s]=e,s++;return t},t.shiftToFitWindow=function(t,e){var r=document.getElementsByTagName("body")[0],o=window.innerWidth||document.documentElement.clientWidth||r.clientWidth,n=t+e,i=0;return n>o&&t+(i=o-n-10)<0&&(i=10-t),i},t.isObject=function(t){return null!==t&&("function"==typeof t||"object"==typeof t)},t.isNumericType=function(t){return e.indexOf(t)>=0},t.isIntType=function(t){return r.indexOf(t)>=0},t.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.areCompatibleDataTypes=function(t,e){return void 0===t||void 0===e||t==o.Unknown||e==o.Unknown||t==e||t==o.Date&&e==o.DateTime||t==o.DateTime&&e==o.Date},t.isPropSet=function(t,e){return t[e]||t[e.toLowerCase()]||t[e.toUpperCase()]};var s="0123456789abcdefghijklmnopqrstuvwxyz";function u(t,e){var r=t.length;if(r>e){var o=r/e,n="";n+=t[0];for(var i=o,s=void 0,a=1;a<r;a++)s=t[a],a+1>i&&(n+=s,i+=o);return n}return t}function l(t,e,r){return t.substr(0,e)+r+t.substr(e+r.length)}function d(t,e){return Math.floor(Math.random()*(e-t))+t}function h(t){var e=parseInt(t);if(isNaN(e))throw'"'.concat(t,'" is not a valid number');return e}t.generateId=function(t){t||(t="easy");var e=t.length>4?function(t,e){var r=t.split("-"),o=1,n=e;r.length<e&&(o=e/r.length,n=r.length);for(var i="",s=0;s<n;s++)i+=u(r[s],o);return i}(t,4):t;e&&e.length>0&&(e+="-");var r=c("",2),o=s.length-1;return r=l(r,0,s[d(0,o)]),e+(r=l(r,1,s[d(0,o)]))+function(t){var e=36,r=14,o=c("",r),n=t;do{o=l(o,r--,s[n%e]),n=Math.floor(n/=e)}while(n>0);return i=o.trim(),i.split("").reverse().join("");var i}(621355968e9+1e4*(new Date).getTime()-0x8d60e562e627800)},t.strToDateTime=function(t,e){if(!t||0==t.length)return new Date;var r=t.replace(/[^a-zA-Z0-9_]/g,"-"),o=e.replace(/[^a-zA-Z0-9_]/g,"-").split("-"),n=r.split("-"),i=o.indexOf("MM"),s=o.indexOf("dd"),a=o.indexOf("yyyy"),u=o.indexOf("HH"),l=o.indexOf("mm"),c=o.indexOf("ss"),d=new Date;try{var p=a>-1&&a<n.length?h(n[a]):d.getFullYear(),f=i>-1&&i<n.length?h(n[i])-1:d.getMonth()-1;if(f>11)throw"";var g=s>-1&&s<n.length?h(n[s]):d.getDate();if(g>function(t,e){return new Date(e,t+1,0).getDate()}(f,p))throw"";var y=u>-1&&u<n.length?h(n[u]):0;if(y>23)throw"";var m=l>-1&&l<n.length?h(n[l]):0;if(m>59)throw"";var v=c>-1&&c<n.length?h(n[c]):0;if(v>59)throw"";return new Date(p,f,g,y,m,v)}catch(e){throw"".concat(t," is not a valid date.")}},t.strToTime=function(t){var e=t.split(":");try{var r=e.length>0?h(e[0]):0;if(r>23)throw"";var o=e.length>1?h(e[1]):0;if(o>59)throw"";var n=e.length>1?h(e[1]):0;if(n>59)throw"";return new Date(0,0,0,r,o,n)}catch(e){throw"".concat(t," is not a valid time.")}};var p=/\[([^\]]+)]|y{2,4}|M{1,4}|d{1,2}|H{1,2}|h{1,2}|m{2}|s{2}|t{2}/g;t.dateTimeToStr=function(t,e){var r=t.getFullYear().toString(),o=t.getMonth()+1,n=t.getDate(),i=t.getHours(),s=t.getMinutes(),u=t.getSeconds(),l=i%12||12,c=i>11,d={yyyy:r,yy:r.substring(r.length-2),MMMM:a.getLongMonthName(o),MMM:a.getShortMonthName(o),MM:o<10?"0"+o:o.toString(),M:o.toString(),dd:n<10?"0"+n:n.toString(),d:n.toString(),HH:i<10?"0"+i:i.toString(),H:i.toString(),hh:l<10?"0"+l:l.toString(),h:l.toString(),tt:c?"PM":"AM",mm:s<10?"0"+s:s.toString(),ss:u<10?"0"+u:u.toString()};return e.replace(p,(function(t,e){return e||d[t]}))},t.numberToStr=function(t,e){return e=e||a.getLocaleSettings().decimalSeparator,t.toString().replace(".",e)}}(u||(u={}));var d,h,p=function(){function t(t,e){this.request=t,this.promise=e}return t.prototype.getPromise=function(){return this.promise},t.prototype.getRequest=function(){return this.request},t.prototype.then=function(t,e){return this.promise.then(t,e)},t.prototype.catch=function(t){return this.promise.catch(t)},t.prototype.finally=function(t){return this.promise.finally(t)},t}(),f=(d=function(t,e){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},d(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),g=function(){return g=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},g.apply(this,arguments)},y=function(t){function e(e,r){var o=t.call(this,r)||this;return o.status=e,o}return f(e,t),e}(Error),m=function(){function t(){this.defaultHeaders={},this.customPayload=void 0}return Object.defineProperty(t.prototype,"responseBody",{get:function(){return this._responseBody},enumerable:!1,configurable:!0}),t.prototype.get=function(t,e){return this.send(i.Get,t,null,e)},t.prototype.post=function(t,e,r){return this.send(i.Post,t,e,r)},t.prototype.put=function(t,e,r){return this.send(i.Put,t,e,r)},t.prototype.delete=function(t,e,r){return this.send(i.Delete,t,e,r)},t.prototype.send=function(e,r,o,n){var i=this,s=(n=n||{}).dataType||"json",a=n.contentType||"form-data"!==s?"application/json":null;o&&"form-data"!=s&&this.customPayload&&(o.data=u.assignDeep(o.data||{},this.customPayload));var c=new("onload"in new XMLHttpRequest?XMLHttpRequest:window.XDomainRequest),d={method:e,url:r,headers:g(g({},this.defaultHeaders),n.headers||{}),queryParams:n.queryParams||{},data:o};a&&(d.headers["Content-Type"]=a);var h=new l(c,d);this.beforeEachRequest&&(console.warn("HttpClient: 'beforeEachRequest' is deprecated and will be removed in future updates.\n Use 'onRequest' instead"),this.beforeEachRequest(h)),this.onRequest&&this.onRequest(h);var f=h.data&&"string"!=typeof h.data&&"json"==s?JSON.stringify(h.data):h.data;return h.open(),new p(h,new Promise((function(e,o){n.responseType&&(c.responseType=n.responseType),c.onerror=function(t){o(new y(c.status,c.responseText))},c.onreadystatechange=function(){if(4==c.readyState){var n=c.getResponseHeader("Content-Type")||"",s=c.status;if(0===s)o(new y(s,"Network error or the request was aborted"));else if(s>=200&&s<400){var a="arraybuffer"===c.responseType||"blob"===c.responseType?c.response:0==n.indexOf("application/json")?JSON.parse(c.responseText):c.responseText;i._responseBody=a,i.onResponse&&i.onResponse(c),e(a)}else{("arraybuffer"===c.responseType||"blob"===c.responseType?t.decodeArrayBuffer(c.response):Promise.resolve(c.responseText)).then((function(t){var e=0==n.indexOf("application/json")?JSON.parse(t):t;i._responseBody=e;var a=e.message||(404==s?"No such endpoint: ".concat(r):e);o(new y(s,a))}))}}},c.send(f)})))},t.decodeArrayBuffer=function(t){var e=new FileReader;return new Promise((function(r){e.onloadend=function(){e.readyState==FileReader.DONE&&r(e.result)},e.readAsText(new Blob([t]))}))},t}(),v=function(){function t(t){this.isEditable=!0,this.name="",this.caption="",this.description="",this.parent=t,this.attributes=new Array,this.subEntities=new Array}return t.prototype.loadFromData=function(t,e){if(e){if(this.id=e.id,this.name=e.name,this.captionPlural=e.namePlur,this.caption=e.name,this.description=e.desc,void 0!==e.ied&&(this.isEditable=e.ied),this.subEntities=new Array,e.ents)for(var r=0;r<e.ents.length;r++){var o=t.createEntity(this);o.loadFromData(t,e.ents[r]),this.subEntities.push(o)}if(this.attributes=new Array,e.attrs)for(r=0;r<e.attrs.length;r++){var n=t.createEntityAttr(this);n.loadFromData(t,e.attrs[r]),this.attributes.push(n)}}},t.prototype.scan=function(t,e){var r={stop:!1},o=function(n){if(e&&e(n,r),n.attributes)for(var i=n.attributes.length,s=0;s<i&&!r.stop;s++){var a=n.attributes[s];if(t&&t(a,r),r.stop)return}if(n.subEntities){var u=n.subEntities.length;for(s=0;s<u&&!r.stop;s++)o(n.subEntities[s])}};o(this)},t.prototype.getFirstPrimaryAttr=function(){return this.getPrimaryAttrs()[0]},t.prototype.getPrimaryAttrs=function(){return this.attributes.filter((function(t){return t.isPrimaryKey}))},t}(),x=function(){function t(t){this.id="",this.caption="{Unrecognized attribute}",this.dataType=o.String,this.size=0,this.isPrimaryKey=!1,this.isForeignKey=!1,this.isNullable=!0,this.showOnView=!0,this.isEditable=!0,this.showOnCreate=!0,this.showOnEdit=!0,this.showInLookup=!1,this.lookupAttr="",this.expr="",this.entity=t,this.kind=n.Data}return t.prototype.loadFromData=function(t,e){if(e){this.id=e.id,this.description=e.desc,this.caption=e.cptn,this.dataType=e.dtype,this.isPrimaryKey=e.ipk,this.isForeignKey=e.ifk,this.size=e.size,this.lookupAttr=e.lattr,this.lookupEntity=e.lent,this.dataAttr=e.dattr,this.lookupDataAttr=e.ldattr;var r=u.getDateDataTypes().indexOf(this.dataType);this.defaultValue=e.defVal&&r?new Date(e.defVal):e.defVal,this.isNullable=u.getIfDefined(e.nul,this.isNullable),this.isEditable=u.getIfDefined(e.ied,this.isEditable),this.showOnView=u.getIfDefined(e.ivis||e.sov,this.showOnView),this.showOnCreate=u.getIfDefined(e.soc,this.showOnCreate),this.showOnEdit=u.getIfDefined(e.soe,this.showOnEdit),this.showInLookup=u.getIfDefined(e.sil,this.showInLookup),this.kind=e.kind,this.displayFormat=e.dfmt,e.udata&&(this.userData=e.udata),e.edtr&&(this.defaultEditor=t.getEditorById(e.edtr)||t.createValueEditor())}},t}(),b=function(){function t(){this.id="",this.tag=s.Unknown,this.resType=o.Unknown,this.defValue=""}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.tag=t.tag,this.defValue=t.defval,this.resType=t.rtype,this.accept=t.accept,this.multiline=t.multiline,t.subType&&(this.resType=t.subType),t.name&&(this.name=t.name),t.values&&(this.values=t.values))},t.prototype.getValueText=function(t){var e="";if(!this.values)return e;if(Array.isArray(t))for(var r=0,o=this.values;r<o.length;r++){var n=o[r];t.indexOf(n.id)>=0&&(e+=n.text+",")}else for(var i=0,s=this.values;i<s.length;i++){(n=s[i]).id===t&&(e+=n.text+",")}return e&&(e=e.substring(0,e.length-1)),e},t}(),E=function(){function t(){this.mainEntity=null,this.id="__none",this.name="Empty model",this.rootEntity=this.createEntity(),this.displayFormats=new Map}return t.prototype.getMainEntity=function(){return this.mainEntity},t.prototype.createEntity=function(t){return new v(t)},t.prototype.createEntityAttr=function(t){return new x(t)},t.prototype.createValueEditor=function(){return new b},t.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},t.prototype.loadFromData=function(t){if(this.id=t.id,this.name=t.name,this.version=t.vers,this.editors=new Array,t.editors)for(var e=0;e<t.editors.length;e++){var r=this.createValueEditor();r.loadFromData(t.editors[e]),this.editors.push(r)}if(this.rootEntity.loadFromData(this,t.entroot),this.displayFormats=new Map,t.displayFormats)for(var n in t.displayFormats){var i=o[n],s=t.displayFormats[n]||new Array;this.displayFormats.set(i,s)}},t.prototype.getDisplayFormats=function(){return this.displayFormats},t.prototype.getDisplayFormatsForType=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t):[]},t.prototype.getDefaultFormat=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t).filter((function(t){return t.isdef}))[0]:null},t.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},t.prototype.isEmpty=function(){return 0===this.rootEntity.subEntities.length&&0===this.rootEntity.attributes.length},t.prototype.getId=function(){return this.id},t.prototype.getName=function(){return this.name},t.prototype.getRootEntity=function(){return this.rootEntity},t.prototype.getEditorById=function(t){for(var e=0,r=this.editors;e<r.length;e++){var o=r[e];if(o.id===t)return o}return null},t.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||null},t.prototype.checkAttrProperty=function(t,e){var r=this.getAttributeById(t);if(r){if(void 0===r[e])throw"No such property: "+e;return!!r[e]||!!r.lookupAttr&&(t=r.lookupAttr,(r=this.getAttributeById(t))&&r[e])}return!1},t.prototype.getEntityAttrById=function(t,e){var r,o;if(t.attributes){var n=t.attributes.length;for(r=0;r<n;r++)if(t.attributes[r].id==e)return t.attributes[r]}if(t.subEntities){var i=t.subEntities.length;for(r=0;r<i;r++)if(o=this.getEntityAttrById(t.subEntities[r],e))return o}return null},t.prototype.listByEntityWithFilter=function(t,e){var r,o=new Array,n=null;if(t.subEntities)for(var i=t.subEntities.length,s=0;s<i;s++){if(n=t.subEntities[s],!e||e(n,null))(r=a.getText("Entities",n.name))||(r=n.caption),(h=u.assign(this.createEntity(),{id:n.name,text:r,items:[],isEntity:!0})).items=this.listByEntityWithFilter(n,e),h.items.length>0&&o.push(h)}var l=null;if(t.attributes)for(var c=t.attributes.length,d=0;d<c;d++)if(l=t.attributes[d],!e||e(t,l)){(r=a.getText("Attributes",l.id))||(r=l.caption);var h=u.assign(this.createEntity(),{id:l.id,text:r,dataType:l.dataType});o.push(h)}return o},t.prototype.listByEntity=function(t,e,r){e=e||{};var o,n=[],i=[],s=null;if(t.subEntities)for(var l=t.subEntities.length,c=0;c<l;c++)if(s=t.subEntities[c],!r||r(s,null)){o=a.getText("Entities",s.name)||s.caption;var d=u.assign(this.createEntity(),{id:s.name,text:o,items:[],isEntity:!0,description:s.description}),h=u.assign({},e);h.includeRootData=!1,d.items=this.listByEntity(s,h,r),d.items.length>0&&n.push(d)}var p=null;if(t.attributes)for(var f=t.attributes.length,g=0;g<f;g++)p=t.attributes[g],r&&!r(t,p)||(o=a.getText("Attributes",p.id)||p.caption,i.push(u.assign(this.createEntityAttr(t),{id:p.id,text:o,dataType:p.dataType,lookupAttr:p.lookupAttr,description:p.description})));var y,m=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(n.sort(m),i.sort(m)),y=e.attrPlacement&&0!=e.attrPlacement?i.concat(n):n.concat(i),2==e.attrPlacement&&y.sort(m),e.includeRootData?((o=a.getText("Entities",t.name))||(o=t.caption),{id:t.name,text:o,items:y}):y},t.prototype.clear=function(){this.rootEntity=this.createEntity(),this.editors=[],this.version=""},t.prototype.addDefaultValueEditors=function(){this.addOrUpdateValueEditor("_DTE",s.Edit,o.String).defValue="",this.addOrUpdateValueEditor("_DPDE",s.DateTime,o.DateTime),this.addOrUpdateValueEditor("_DPTE",s.DateTime,o.DateTime)},t.prototype.addOrUpdateValueEditor=function(t,e,r){var o=u.findItemById(this.editors,t);return o||((o=this.createValueEditor()).id=t,this.editors.push(o)),o.tag=e,o.resType=r,o},t.prototype.getEntitiesTree=function(t,e){return this.listByEntity(this.getRootEntity(),t,e)},t.prototype.getEntitiesTreeWithFilter=function(t){return this.listByEntityWithFilter(this.getRootEntity(),t)},t.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},t.prototype.getEntityPathByAttr=function(t,e,r,o){if(!t)return"";r=r||" ";var n="";if(t.caption&&!o){var i=a.getText("Entities",t.caption);n=i||t.caption}if(t.attributes)for(var s=t.attributes.length,u=0;u<s;u++)if(t.attributes[u].id==e)return n;if(t.subEntities){var l=t.subEntities.length;for(u=0;u<l;u++){var c=t.subEntities[u],d=this.getEntityPathByAttr(c,e,r,!1);if(""!==d)return""!==n&&(d=n+r+d),d}}return""},t.prototype.getAttributeText=function(t,e){var r=a.getText("Attributes",t.id);if(r||(r=t.caption),!e)return r;var o=this.getFullEntityPathByAttr(t.id," ");return(o?e.replace(new RegExp("{attr}","g"),r).replace(new RegExp("{entity}","g"),o):r).trim()},t.prototype.runThroughEntities=function(t,e){this.getRootEntity().scan(t,e)},t.prototype.getFirstAttributeByFilter=function(t){var e=null;return this.runThroughEntities((function(r,o){t(r)&&(o.stop=!0,e=r)}),null),e},t}(),C=function(){return C=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},C.apply(this,arguments)},T=function(){function t(t){this.colStore=t,this.aggregates=[],this.groups=[],this.useGrandTotals=!1,this.useRecordCount=!1,this._caseSensitiveGroups=!1,this.COUNT_FIELD_NAME="GRPRECCNT"}return Object.defineProperty(t.prototype,"caseSensitiveGroups",{get:function(){return this._caseSensitiveGroups},set:function(t){this._caseSensitiveGroups=t,this.updateCompareProc()},enumerable:!1,configurable:!0}),t.prototype.updateCompareProc=function(){this.compareValues=this._caseSensitiveGroups?this.strictCompare:this.caseInsensitiveCompare},t.prototype.addGroup=function(t){var e=t.columns||this.colStore.getColumnIds(t.from,t.to);if(!this.colStore.validateColumns(e))throw"Invalid columns: "+e;if(this.hasColumnsInUse(e))throw"Can't add same columns to different groups/aggregates";return this.groups.push(C({columns:e},t)),this},t.prototype.addAggregateColumn=function(t,e){var r="string"==typeof t?t:this.colStore.getColumnIds(t,t)[0];if(this.hasColumnsInUse([r])||!this.colStore.validateAggregate(r,e))throw"Invalid aggregation function for the column: "+r;return this.aggregates.push({colId:r,funcId:e}),this},t.prototype.addGrandTotals=function(){return this.useGrandTotals=!0,this},t.prototype.addCounts=function(){return this.useRecordCount=!0,this},t.prototype.getGroups=function(){var t=this,e=[];return this.groups.map((function(r){return e=e.concat(r.columns),C(C({},r),{columns:Array.from(e),aggregates:Array.from(t.aggregates)})}))},t.prototype.getInternalGroups=function(){return this.groups},t.prototype.lastGroup=function(){var t=this.getGroups();return t[t.length-1]},t.prototype.getAggregates=function(){return this.aggregates},t.prototype.hasAggregates=function(){return this.aggregates.length>0},t.prototype.hasGroups=function(){return this.groups.length>0},t.prototype.hasGrandTotals=function(){return this.useGrandTotals},t.prototype.hasRecordCount=function(){return this.useRecordCount},t.prototype.isEmpty=function(){return!(this.hasAggregates()||this.hasGroups()||this.hasAggregates()||this.hasRecordCount())},t.prototype.drop=function(){console.warn('"drop()" method is obsolete. Use "clear()" instead'),this.clear()},t.prototype.clear=function(){return this.groups=[],this.aggregates=[],this.useGrandTotals=!1,this.useRecordCount=!1,this.caseSensitiveGroups=!1,this},t.prototype.hasColumnsInUse=function(t){for(var e=0,r=this.groups;e<r.length;e++){if(r[e].columns.filter((function(e){return t.indexOf(e)>=0})).length>0)return!0}for(var o=0,n=this.aggregates;o<n.length;o++){var i=n[o];if(t.indexOf(i.colId)>=0)return!0}return!1},t.prototype.needAggrCalculation=function(){return(this.hasAggregates()||this.hasRecordCount())&&(this.hasGrandTotals()||this.hasGroups())},t.prototype.saveToData=function(){return{groups:Array.from(this.groups),ugt:this.useGrandTotals,urc:this.useRecordCount,csg:this.caseSensitiveGroups,aggregates:Array.from(this.aggregates)}},t.prototype.loadFromData=function(t){t&&(void 0!==t.ugt&&(this.useGrandTotals=t.ugt),void 0!==t.urc&&(this.useRecordCount=t.urc),void 0!==t.csg&&(this.caseSensitiveGroups=t.csg),t.groups&&(this.groups=Array.from(t.groups)),t.aggregates&&(this.aggregates=Array.from(t.aggregates)))},t.prototype.buildGroupKey=function(t,e){var r=!this.caseSensitiveGroups,o={};if(t)for(var n=0,i=t.columns;n<i.length;n++){var s=i[n],a=e.getValue(s);r&&"string"==typeof a&&(a=a.toLowerCase()),o[s]=a}return o},t.prototype.strictCompare=function(t,e){return t instanceof Date?t.getTime()===e.getTime():t===e},t.prototype.caseInsensitiveCompare=function(t,e){return t instanceof Date?t.getTime()===e.getTime():("string"==typeof t?t.toLowerCase():t)===("string"==typeof e?e.toLowerCase():e)},t}();!function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Center=2]="Center",t[t.Right=3]="Right"}(h||(h={}));var I,w=function(t){if(!t)throw Error("Options are required");if(!t.id)throw Error("Field Id is required");if(!t.label)throw Error("Label is required");this.id=t.id,this.type=u.getIfDefined(t.type,o.String),this.label=t.label,this.originAttrId=t.originAttrId,this.isAggr=t.isAggr||!1,this.displayFormat=t.dfmt,this.groupFooterColumnTemplate=t.gfct,this.style=t.style||{},this.description=t.description,this.calculatedWidth=0},S=function(){function t(){this.items=[],this.mapper={},this._dateColumnIdx=[]}return Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!1,configurable:!0}),t.prototype.add=function(t){var e;e=t instanceof w?t:new w(t);var r=this.items.length;return this.items.push(e),this.mapper[e.id]=r,[o.Date,o.DateTime,o.Time].indexOf(e.type)>=0&&this._dateColumnIdx.push(r),r},t.prototype.updateDateColumnIdx=function(){this._dateColumnIdx=this.getItems().filter((function(t){return[o.Date,o.DateTime,o.Time].indexOf(t.type)>=0})).map((function(t,e){return e}))},t.prototype.put=function(t,e){t>=0&&t<this.count&&(this.items[t]=e,this.updateDateColumnIdx())},t.prototype.move=function(t,e){var r=this.items.indexOf(t);r>=0&&r!=e&&(u.moveArrayItem(this.items,r,e),this.updateDateColumnIdx())},t.prototype.get=function(t){return t>=0&&t<this.count?this.items[t]:null},t.prototype.getIndex=function(t){return this.mapper[t]},t.prototype.getItems=function(){return this.items},t.prototype.getDateColumnIndexes=function(){return this._dateColumnIdx},t.prototype.removeAt=function(t){var e=this.get(t);this.items.splice(t,1);var r=this._dateColumnIdx.indexOf(t);r>=0&&this._dateColumnIdx.splice(r,1),delete this.mapper[e.id]},t.prototype.clear=function(){this.items=[],this._dateColumnIdx=[],this.mapper={}},t}(),D=function(){function t(t,e){this.columns=t,this.values=e}return t.prototype.toArray=function(){return Array.from(this.values)},t.prototype.size=function(){return this.values.length},t.prototype.getValue=function(t){var e;if("string"==typeof t){if(void 0===(e=this.columns.getIndex(t)))throw new RangeError("No column with id '".concat(t,"'"))}else e=t;if(e>=this.values.length)throw new RangeError("Out of range: "+e);return this.values[e]},t.prototype.setValue=function(t,e){var r;if("string"==typeof t){if(void 0===(r=this.columns.getIndex(t)))throw new RangeError("No column with id '".concat(t,"'"))}else r=t;if(r>=this.values.length)throw new RangeError("Out of range: "+r);this.values[r]=e},t}(),A=function(){function t(t){if(this._chunkSize=1e3,this._elasticChunks=!1,this.cachedRows=[],this.total=0,this.loader=null,this.needTotal=!0,this.isInMemory=!1,t=t||{},this._chunkSize=t.chunkSize||this._chunkSize,this._elasticChunks=t.elasticChunks||this._elasticChunks,this.loader=t.loader,void 0!==t.inMemory&&(this.isInMemory=t.inMemory),this.isInMemory&&(this.needTotal=!1),this._columns=new S,this.onUpdate=t.onUpdate,t.columns)for(var e=0,r=t.columns;e<r.length;e++){var o=r[e];this._columns.add(o)}if(t.rows)for(var n=0,i=t.rows;n<i.length;n++){var s=i[n],a=this.createRow(s);this.addRow(a)}this.needTotal=!this._elasticChunks}return Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chunkSize",{get:function(){return this._chunkSize},set:function(t){this._chunkSize=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"elasticChunks",{get:function(){return this._elasticChunks},set:function(t){this._elasticChunks=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!1,configurable:!0}),t.prototype.getRows=function(t){var e=this,r=0,o=this._chunkSize;t&&("page"in t?(r=t.pageSize*(t.page-1),o=t.pageSize):(r=t.offset,o=t.limit));var n=r+o;if(!this.needTotal&&!this.elasticChunks){if(r>=this.total)return Promise.resolve([]);n>this.total&&(n=this.total)}if(this.isInMemory&&n>this.cachedRows.length&&(n=this.cachedRows.length),n<=this.cachedRows.length)return Promise.resolve(this.cachedRows.slice(r,n));if(!this.loader)throw"Loader is not defined. Can't get the rows from ".concat(r," to ").concat(n);var i=this.needTotal;this.needTotal&&(this.needTotal=!1);var s=this.cachedRows.length,a=n-s;return a<this._chunkSize&&(a=this._chunkSize),this.loader.loadChunk({offset:s,limit:a,needTotal:i}).then((function(t){(i&&(e.total=t.total),Array.prototype.push.apply(e.cachedRows,t.table.getCachedRows()),n>e.cachedRows.length&&(n=e.cachedRows.length),e.elasticChunks)&&(t.table.getCachedCount()<a&&(e.total=e.cachedRows.length));return e.fireUpdated(),e.cachedRows.slice(r,n)}))},t.prototype.getRow=function(t){return this.getRows({offset:t,limit:1}).then((function(t){return t.length>0?t[0]:null}))},t.prototype.getTotal=function(){return this.total},t.prototype.setTotal=function(t){this.total=t,this.needTotal=!1},t.prototype.getCachedCount=function(){return this.cachedRows.length},t.prototype.clear=function(){this.columns.clear(),this.cachedRows=[],this.total=0,this.needTotal=!this._elasticChunks,this.fireUpdated()},t.prototype.createRow=function(t){var e=this,r=this._columns.getDateColumnIndexes(),o=new Array(this._columns.count),n=t instanceof D?function(e){return t.getValue(e)}:function(e){return t[e]};return t&&this.columns.getItems().forEach((function(t){var i=n(t.id),s=e.columns.getIndex(t.id);o[s]=r.indexOf(s)>=0?e.mapDate(i,t.type):i})),new D(this._columns,o)},t.prototype.mapDate=function(t,e){if(t){var r=new Date(t);return isNaN(r.getTime())&&e==o.Time&&(r=u.strToTime(t)),r}return null},t.prototype.addRow=function(t){var e;if(Array.isArray(t)){var r=t,o=this._columns.getDateColumnIndexes();if(o.length>0)for(var n=0,i=o;n<i.length;n++){var s=i[n];r[s]&&(r[s]=this.mapDate(r[s],this._columns.get(s).type))}e=new D(this._columns,r)}else e=this.createRow(t);this.cachedRows.push(e);var a=this.getCachedCount();return a>this.total&&(this.total=a),e},t.prototype.getCachedRows=function(){return this.cachedRows},t.prototype.totalIsKnown=function(){return this.elasticChunks?this.getCachedCount()===this.total:!this.needTotal},t.prototype.fireUpdated=function(){this.onUpdate&&this.onUpdate(this)},t}(),_=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},t}(),O=function(){function t(t){this.silentMode=0,this.events=new Array,this.source=t}return t.prototype.subscribe=function(t,e){var r=this.getEventRecByType(t),o={id:_.newGuid(),callback:e};return r?r.eventCallbacks.push(o):(r={type:t,eventCallbacks:new Array(o)},this.events.push(r)),o.id},t.prototype.unsubscribe=function(t,e){var r=this.getEventRecByType(t);if(r){var o=-1;for(o=0;o<r.eventCallbacks.length&&r.eventCallbacks[o].id!==e;o++);o>=0&&r.eventCallbacks.splice(o,1)}},t.prototype.fire=function(t,e,r,o){if(void 0===r&&(r=0),void 0===o&&(o=!1),!this.silentMode||o){var n=this.getEventRecByType(t);if(n){var i={type:t,source:this.source,data:e},s=function(){for(var t=0,e=n.eventCallbacks;t<e.length;t++){e[t].callback(i)}};r>0?setTimeout(s,r):s()}}},t.prototype.enterSilentMode=function(){this.silentMode++},t.prototype.exitSilentMode=function(){this.silentMode&&this.silentMode--},t.prototype.isSilent=function(){return this.silentMode>0},t.prototype.getEventRecByType=function(t){for(var e=0,r=this.events;e<r.length;e++){var o=r[e];if(o.type==t)return o}return null},t}();!function(t){t.renderLiquidTemplate=function(t,e){var r=t;if(e)for(var o in e){var n=new RegExp("{{"+o+"}}","g");r=r.replace(n,e[o])}return r}}(I||(I={})),a.resetLocales(),"function"!=typeof Object.values&&(Object.values=function(t){return Object.keys(t).map((function(e){return t[e]}))}),"function"!=typeof Math.trunc&&(Math.trunc=function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)})}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=(t,e)=>{for(var r in e)__webpack_require__.o(e,r)&&!__webpack_require__.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),__webpack_require__.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{AggrFunction:()=>u,BrowserQueryStorage:()=>k,CondTag:()=>S,Condition:()=>F,ConditionPart:()=>D,DataKind:()=>s,DataModel:()=>I,DefaultAggregatesCalculator:()=>V,EasyQueryDataLoader:()=>H,EmptyChunk:()=>a,Entity:()=>g,EntityAttr:()=>y,EqAction:()=>O,EqActionResult:()=>z,EqAggregatesContainer:()=>U,EqContext:()=>X,EqEditorTag:()=>v,EqModelLoader:()=>L,EqQueryFileLoader:()=>G,EqServerDataFetcher:()=>Q,EqServerExporter:()=>Y,EqServerModelLoader:()=>N,EqServerQuerySynchronizer:()=>B,EqServerValueListResolver:()=>j,EqServiceProvider:()=>W,EqValueEditor:()=>c,ExprTag:()=>d,Expression:()=>w,FormatParser:()=>n,GoogleDataConverter:()=>J.e,InMemoryModelStorage:()=>K,InvalidQueryError:()=>M,LinkType:()=>t,Operand:()=>p,Operator:()=>h,Query:()=>P,QueryChangeAction:()=>b,QueryChangePart:()=>x,QueryColumn:()=>A,SortDirection:()=>E,Tree:()=>C,Widget:()=>Z,WidgetGroup:()=>_,eqconsts:()=>r,equtils:()=>e,i18n:()=>o.ag,versionInfo:()=>tt});var t,e,r,o=__webpack_require__(907),n=function(){function t(t){this.start(t)}return t.prototype.start=function(t){this.formatStr=t,this.pos=0,this.exprNum=0,this.tokenText=""},t.prototype.skipSpaces=function(){for(;this.pos<this.formatStr.length&&" "===this.formatStr.charAt(this.pos);)this.pos++},t.prototype.next=function(){if(this.skipSpaces(),this.pos>=this.formatStr.length)return!1;var t=0;if("{"===this.formatStr.charAt(this.pos)){if((t=this.formatStr.indexOf("}",this.pos))<0)return!1;this.tokenText=this.formatStr.substring(this.pos,t+1),0===this.tokenText.indexOf("{expr")&&(this.token="expression",this.exprNum=parseInt(this.tokenText.substring(5,this.tokenText.length))),this.pos=t+1}else if("["===this.formatStr.charAt(this.pos)&&this.pos<this.formatStr.length-1&&"["===this.formatStr.charAt(this.pos+1))this.pos+=2,t=this.formatStr.indexOf("]]",this.pos),this.token="operator",this.tokenText=this.formatStr.substring(this.pos,t),this.pos=t+2;else{this.token="text";var e=this.formatStr.indexOf("{",this.pos);e<0&&(e=this.formatStr.length);var r=this.formatStr.indexOf("[[",this.pos);r<0&&(r=this.formatStr.length),t=Math.min(e,r),this.tokenText=this.formatStr.substring(this.pos,t).trim(),this.pos=t}return!0},t.prototype.getToken=function(){return{type:this.token,text:this.tokenText,index:this.exprNum-1}},t.prototype.parse=function(){for(var t=[];this.next();)t.push(this.getToken());return t},t}();!function(t){t[t.None=0]="None",t[t.Any=1]="Any",t[t.NotAll=2]="NotAll",t[t.All=3]="All"}(t||(t={})),function(e){e.combinePath=function(t,e){var r=t;return null!=r&&r.length>0?("/"!=r.charAt(r.length-1)&&(r+="/"),r+=e):r=e,r},e.strToLinkType=function(e){return"All"==e?t.All:"NotAll"==e?t.NotAll:"Any"==e?t.Any:t.None},e.linkTypeToStr=function(e){return e===t.All?"All":e===t.NotAll?"NotAll":e==t.Any?"Any":"None"},e.parseOperatorFormat=function(t){var e=o.ag.getText("Operators",t.id,"format");return e||(e=o.ag.getText("Operators",t.id,"displayFormat")),e||(e=t.displayFormat),new n(e).parse()},e.convertValue=function(t,e,r){switch(r){case o.g.String:return t;case o.g.Autoinc,o.g.Byte,o.g.Int32,o.g.Int64,o.g.Word:var n=parseInt(t);return isNaN(n)?"":n.toString();case o.g.Currency,o.g.Float:var i=parseFloat(t);return isNaN(i)?"":i.toString();default:return""}}}(e||(e={})),function(t){var e=function(){this.SpecDateValues=[{id:"${Today}",key:"Today",isDefault:!0},{id:"${Yesterday}",key:"Yesterday"},{id:"${Tomorrow}",key:"Tomorrow"},{id:"${FirstDayOfMonth}",key:"FirstDayOfMonth"},{id:"${FirstDayOfYear}",key:"FirstDayOfYear"}],this.SpecTimeValues=[{id:"${Now}",key:"Now",isDefault:!0},{id:"${HourStart}",key:"HourStart"},{id:"${Midnight}",key:"Midnight"},{id:"${Noon}",key:"Noon"}],this.BooleanValues=[{id:"${false}",key:"False"},{id:"${true}",key:"True",isDefault:!0}]};t.constLists=new e,t.predicateLinkTypeList=[{id:"All",key:"LinkTypeAll"},{id:"Any",key:"LinkTypeAny"},{id:"None",key:"LinkTypeNone"},{id:"NotAll",key:"LinkTypeNotAll"}]}(r||(r={}));var i,s,a={offset:0,limit:0,needTotal:!1},u=function(){function t(){this.id="",this.caption="",this.sqlExpr="",this.displayFormat="",this.appliedTypes=[]}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.caption=t.cptn,this.displayFormat=t.fmt,this.sqlExpr=t.expr,this.appliedTypes=t.dtypes||this.appliedTypes)},t.prototype.getAppliedTypesOrDefault=function(){return this.appliedTypes.length>0?this.appliedTypes:"SUM"===this.id||"AVG"===this.id?[o.g.Autoinc,o.g.Byte,o.g.Currency,o.g.Float,o.g.Int32,o.g.Int64,o.g.Word]:"MIN"===this.id||"MAX"===this.id?[o.g.Autoinc,o.g.BCD,o.g.Byte,o.g.Currency,o.g.Date,o.g.DateTime,o.g.Time,o.g.Float,o.g.Int32,o.g.Int64,o.g.Word]:o.P6.getAllDataTypes()},t}(),l=(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),c=function(t){function e(){return t.call(this)||this}return l(e,t),e.prototype.loadFromData=function(e){t.prototype.loadFromData.call(this,e),e&&(e.sql&&(this.statement=e.sql),e.extraParams&&(this.extraParams=e.extraParams))},e}(o.S$);!function(t){t[t.Scalar=0]="Scalar",t[t.Const=1]="Const",t[t.Attribute=2]="Attribute",t[t.List=4]="List",t[t.Query=5]="Query",t[t.ParentColumn=6]="ParentColumn"}(s||(s={}));var d,h=function(){function t(){this.id="",this.expr="",this.constValueFormat="{const}",this.caption="{Unrecognized operator}",this.displayFormat="{expr1} [[{unrecognized operator}]] {expr2}",this.isRange=!1,this.caseIns=!1,this.paramCount=2,this.defaultOperand=new p,this.appliedTypes=[],this.operands=new Array}return t.prototype.loadFromData=function(t,e){if(e&&(this.id=e.id,this.caption=e.cptn,this.caseIns=e.caseIns,this.isRange=e.isRange,this.displayFormat=e.fmt,this.paramCount=e.pcnt,this.expr=e.expr,this.appliedTypes=e.dtypes||this.appliedTypes,e.defOperand&&this.defaultOperand.loadFromData(t,e.defOperand),e.editor&&(this.defaultOperand.editor=t.getEditorById(e.editor)||new c),e.operands))for(var r=0;r<e.operands.length;r++){var o=new p;o.loadFromData(t,e.operands[r]),e.editor&&(o.editor=t.getEditorById(e.editor)||new c),this.operands.push(o)}},t}(),p=function(){function t(){this.kind=s.Scalar,this.dataType=o.g.Unknown,this.editor=new c,this.defValue=""}return t.prototype.loadFromData=function(t,e){this.kind=e.kind,this.dataType=e.dtype,this.defValue=e.val,this.defText=e.txt,e.editor&&(this.editor=t.getEditorById(e.editor)||new c)},t.prototype.copyFrom=function(t){o.P6.assign(this,t)},t}(),f=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),g=function(t){function e(e){var r=t.call(this,e)||this;return r.useInConditions=!1,r.useInResult=!1,r.useInSorting=!1,r}return f(e,t),e.prototype.loadFromData=function(e,r){t.prototype.loadFromData.call(this,e,r),r&&(this.useInConditions=r.uic,this.useInResult=r.uir,this.useInSorting=r.uis)},e.prototype.scan=function(e,r){t.prototype.scan.call(this,(function(t,r){return e&&e(t,r)}),(function(t,e){return r&&r(t,e)}))},e}(o.qR),y=function(t){function e(e){var r=t.call(this,e)||this;return r.params=[],r.useInConditions=!0,r.useInResult=!0,r.useInSorting=!0,r.defaultOperator="",r.operators=new Array,r.lookupAttr="",r.expr="",r}return f(e,t),e.prototype.loadFromData=function(e,r){t.prototype.loadFromData.call(this,e,r),r&&(this.useInConditions=r.uic,this.useInResult=r.uir,this.useInSorting=r.uis,this.expr=r.sql,this.defaultOperator=r.defOperator,this.operators=r.ops,r.udata&&(this.userData=r.udata))},e}(o.uF),m=function(){return m=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},m.apply(this,arguments)},v=m(m({},o.mb),{SqlList:"SQLLIST",SubQuery:"SUBQUERY",BindToParentColumn:"BINDTOPARENTCOLUMN"});!function(t){t[t.Unknown=0]="Unknown",t[t.Constant=1]="Constant",t[t.EntityAttribute=2]="EntityAttribute",t[t.ParentEntityAttribute=3]="ParentEntityAttribute",t[t.AggregateFunction=4]="AggregateFunction",t[t.ParentColumn=5]="ParentColumn",t[t.Query=11]="Query",t[t.CustomSql=21]="CustomSql"}(d||(d={}));var x,b,E,C=function(){function t(e){void 0===e&&(e=null),this.childs=[],this.value=null,this.parent=null,e&&(Array.isArray(e)?(this.value=e[0],e.length>1&&this.addChild(new t(e.slice(1)))):e instanceof t?(this.value=e.value,this.childs=e.childs):this.value=e)}return t.prototype.contains=function(t){if(this.value===t)return!0;for(var e=0,r=this.childs;e<r.length;e++){if(r[e].contains(t))return!0}return!1},t.prototype.findNode=function(t){if(this.value===t)return this;for(var e=0,r=this.childs;e<r.length;e++){var o=r[e].findNode(t);if(o)return o}return null},t.prototype.addChild=function(t){t.parent=this,this.childs.push(t)},t.prototype.setParents=function(){for(var t=0,e=this.childs;t<e.length;t++){var r=e[t];r.parent=this,r.setParents()}},t}(),T=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),I=function(t){function e(){var e=t.call(this)||this;return e.mainEntity=null,e.nullAttribute=new y(null),e.nullOperator=new h,e.operators=new Array,e.rootEntity=new g,e.aggrFunctions=new Array,e.dateMacros=["Today","Yesterday","Tomorrow","FirstDayOfMonth","LastDayOfMonth","FirstDayOfWeek","FirstDayOfYear","FirstDayOfNextWeek","FirstDayOfPrevMonth","FirstDayOfNextMonth","FirstDayOfNextYear","FirstDayOfPrevYear","FirstDayOfPrevWeek"],e.timeMacros=["Now","HourStart","Midnight","Noon"],e.links=[],e}return T(e,t),e.prototype.getMainEntity=function(){return this.mainEntity},e.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},e.prototype.loadFromData=function(e){if(t.prototype.loadFromData.call(this,e),this.operators=new Array,e.operators)for(var r=0;r<e.operators.length;r++){var o=new h;o.loadFromData(this,e.operators[r]),this.operators.push(o)}if(this.rootEntity.loadFromData(this,e.entroot),this.aggrFunctions=new Array,e.aggrfuncs)for(r=0;r<e.aggrfuncs.length;r++){var n=new u;n.loadFromData(e.aggrfuncs[r]),this.aggrFunctions.push(n)}},e.prototype.getObject=function(){return this},e.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},e.prototype.createEntity=function(t){return new g(t)},e.prototype.createEntityAttr=function(t){return new y(t)},e.prototype.createValueEditor=function(){return new c},e.prototype.createQuery=function(){return new P(this)},e.prototype.getRootEntity=function(){return this.rootEntity},e.prototype.getEditorById=function(e){return t.prototype.getEditorById.call(this,e)},e.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||null},e.prototype.getAttributeByIdSafe=function(t){var e=this.getAttributeById(t);return e||this.nullAttribute},e.prototype.checkAttrProperty=function(t,e){var r=this.getAttributeById(t);if(r){if(void 0===r[e])throw"No such property: "+e;return!!r[e]||!!r.lookupAttr&&(t=r.lookupAttr,(r=this.getAttributeById(t))&&r[e])}return!1},e.prototype.getEntityAttrById=function(e,r){return t.prototype.getEntityAttrById.call(this,e,r)},e.prototype._listByEntityWithFilter=function(t,e){var r,n=new Array,i=null;if(t.subEntities)for(var s=t.subEntities.length,a=0;a<s;a++){if(i=t.subEntities[a],!e||e(i,null))(r=o.ag.getText("Entities",i.name))||(r=i.caption),(d=o.P6.assign(new g,{id:i.name,text:r,items:[],isEntity:!0})).items=this._listByEntityWithFilter(i,e),d.items.length>0&&n.push(d)}var u=null;if(t.attributes)for(var l=t.attributes.length,c=0;c<l;c++)if(u=t.attributes[c],!e||e(t,u)){(r=o.ag.getText("Attributes",u.id))||(r=u.caption);var d=o.P6.assign(new g,{id:u.id,text:r,dataType:u.dataType});n.push(d)}return n},e.prototype._listByEntity=function(t,e,r){e=e||{};var n,i=[],s=[],a=null;if(t.subEntities)for(var u=t.subEntities.length,l=0;l<u;l++)if(a=t.subEntities[l],(!r||r(a,null))&&(!1!==e.addUIC&&!1!==a.useInConditions||!1!==e.addUIR&&!1!==a.useInResult||!1!==e.addUIS&&!1!==a.useInSorting)){n=o.ag.getText("Entities",a.name)||a.caption;var c=o.P6.assign(new g,{id:a.name,text:n,items:[],isEntity:!0,description:a.description}),d=o.P6.assign({},e);d.includeRootData=!1,c.items=this._listByEntity(a,d,r),c.items.length>0&&i.push(c)}var h=null;if(t.attributes)for(var p=t.attributes.length,f=0;f<p;f++)h=t.attributes[f],r&&!r(t,h)||(!1!==e.addUIC&&!1!==h.useInConditions||!1!==e.addUIR&&!1!==h.useInResult||!1!==e.addUIS&&!1!==h.useInSorting)&&(n=o.ag.getText("Attributes",h.id)||h.caption,s.push(o.P6.assign(new y(t),{id:h.id,text:n,dataType:h.dataType,lookupAttr:h.lookupAttr,description:h.description})));var m,v=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(i.sort(v),s.sort(v)),m=e.attrPlacement&&0!=e.attrPlacement?s.concat(i):i.concat(s),2==e.attrPlacement&&m.sort(v),e.includeRootData?((n=o.ag.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:m}):m},e.prototype.clear=function(){t.prototype.clear.call(this),this.operators=[],this.aggrFunctions=[]},e.prototype.addOrUpdateOperator=function(t){var e=o.P6.findItemById(this.operators,t.id);return e||((e=new h).id=t.id,this.operators.push(e)),e.caption=t.caption,e.expr=t.expr||"",e.displayFormat=t.format,e.defaultOperand=new p,e.defaultOperand.kind=t.kind||s.Scalar,t.appliedTypes&&(e.appliedTypes=t.appliedTypes),t.paramCount>0&&(e.paramCount=t.paramCount),this.runThroughEntities((function(t,r){t.operators.indexOf(e.id)<0&&e.appliedTypes.indexOf(t.dataType)>=0&&t.operators.push(e.id)})),e},e.prototype.removeOperator=function(t,e){void 0===e&&(e=!1);var r=o.P6.findItemById(this.operators,t);r&&(e||o.P6.removeArrayItem(this.operators,r),this.runThroughEntities((function(t,e){o.P6.removeArrayItem(t.operators,r.id)})))},e.prototype.getOperatorIdsByDataType=function(t){switch(t){case o.g.String:case o.g.Memo:return"StartsWith,EndsWith,Contains,Equal,InList,NotStartsWith,NotEndsWith,NotContains,NotEqual,NotInList,IsNull,IsNotNull".split(",");case o.g.Guid:return"Equal,NotEqual".split(",");case o.g.Date:case o.g.DateTime:return"DateWithinToday,DateWithinThisWeek,DateWithinPrevWeek,DateWithinThisMonth,DateWithinPrevMonth,DateWithinThisYear,DateWithinPrevYear,DateBeforePrecise,DateAfterPrecise,DatePeriodPrecise,IsNull,IsNotNull".split(",");case o.g.Time:return"TimeBeforePrecise,TimeAfterPrecise,TimePeriodPrecise,IsNull,IsNotNull".split(",");case o.g.Byte:case o.g.Word:case o.g.Int32:case o.g.Int64:case o.g.Float:case o.g.Currency:case o.g.BCD:case o.g.Autoinc:case o.g.Unknown:return"Equal,Between,LessThan,LessOrEqual,GreaterThan,GreaterOrEqual,InList,NotEqual,NotBetween,NotInList,IsNull,IsNotNull".split(",");case o.g.Bool:return"IsTrue,NotTrue".split(",");default:for(var e=[],r=0,n=this.operators;r<n.length;r++){var i=n[r];i.appliedTypes.indexOf(t)>=0&&e.push(i.id)}return e}},e.prototype.buildQueryPath=function(t){var e=this.mainEntity||this.rootEntity,r=this.createTreeNodeFromEntity(e);return r.setParents(),r},e.prototype.createTreeNodeFromEntity=function(t){for(var e=new C(t),r=0,o=t.subEntities;r<o.length;r++){var n=o[r];e.addChild(this.createTreeNodeFromEntity(n))}return e},e.prototype.getEntitiesInQuery=function(t){if(t.model.id!==this.id)throw Error("Model mithmatch");for(var e=[],r=0,o=t.getColumns();r<o.length;r++){var n=o[r];n.enabled&&this.addEntityByExpression(e,n.expr)}var i=t.getRootCondition();return this.fillEntitiesByCondtionGroup(e,i),e},e.prototype.findAggrFunctionById=function(t){for(var e=0,r=this.aggrFunctions;e<r.length;e++){var o=r[e];if(o.id===t)return o}return null},e.prototype.fillEntitiesByCondtionGroup=function(t,e){for(var r=0,o=e.getConditions();r<o.length;r++){var n=o[r];if(n.isGroup())this.fillEntitiesByCondtionGroup(t,n);else for(var i=0,s=n.expressions;i<s.length;i++){var a=s[i];if(this.addEntityByExpression(t,a),a.args)for(var u=0,l=a.args;u<l.length;u++){var c=l[u];this.addEntityByExpression(t,c)}}}},e.prototype.addEntityByExpression=function(t,e){if(e.tag===d.EntityAttribute){var r=e.baseAttrId||e.value;if(r){var n=this.getAttributeById(r);n&&n.entity&&o.P6.indexOfArrayItem(t,n.entity)<0&&t.push(n.entity)}}},e.prototype.findLink=function(t,e){for(var r=0,o=this.links;r<o.length;r++){var n=o[r];if(n.entityFrom==t&&n.entityTo==e)return n}return null},e.prototype.getLinksByEntity=function(t){for(var e=[],r=0,o=this.links;r<o.length;r++){var n=o[r];n.entityFrom!=t&&n.entityTo!=t||e.push(n)}return e},e.prototype.getEntitiesTree=function(t,e){return this._listByEntity(this.getRootEntity(),t,e)},e.prototype.getEntitiesTreeWithFilter=function(t){return this._listByEntityWithFilter(this.getRootEntity(),t)},e.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},e.prototype.getEntityPathByAttr=function(e,r,o,n){return t.prototype.getEntityPathByAttr.call(this,e,r,o,n)},e.prototype.getAttributeText=function(e,r){return t.prototype.getAttributeText.call(this,e,r)},e.prototype.getFirstUICAttr=function(){return this.getFirstUICAttrInEntity(this.getRootEntity())},e.prototype.getFirstUICAttrInEntity=function(t){if(!1!==t.useInConditions){if(t.attributes)for(var e=t.attributes.length,r=0;r<e;r++)if(t.attributes[r].useInConditions)return t.attributes[r];if(t.subEntities){var o=t.subEntities.length;for(r=0;r<o;r++){var n=this.getFirstUICAttrInEntity(t.subEntities[r]);if(n)return n}}}return null},e.prototype.runThroughEntities=function(t,e){this.getRootEntity().scan(t,e)},e.prototype.getFirstAttributeByFilter=function(t){var e=null;return this.runThroughEntities((function(r,o){t(r)&&(o.stop=!0,e=r)}),null),e},e.prototype.findOperatorById=function(t){if(this.operators.length>0)for(var e=this.operators.length,r=0;r<e;r++)if(this.operators[r].id==t)return this.operators[r];return null},e.prototype.getOperatorById=function(t){var e=this.findOperatorById(t);return e||this.nullOperator},e.prototype.getDefaultOperatorIdForAttr=function(t){return t.defaultOperator?t.defaultOperator:t.operators.length>0?t.operators[0]:this.nullOperator.id},e.prototype.getAggrFunctionCaption=function(t){var e=o.ag.getText("AggregateFunctions",t),r=e?e.caption:o.ag.getText("Aggr"+t.replace(" ","")+"_Caption");if(r)return r;var n=o.P6.findItemById(this.aggrFunctions,t);return n&&n.caption?n.caption:t},e.prototype.getAggrFunctionFormat=function(t){var e=o.ag.getText("AggregateFunctions",t),r=e?e.displayFormat:o.ag.getText("Aggr"+t.replace(" ","")+"_Format");if(r)return r;var n=o.P6.findItemById(this.aggrFunctions,t);return n&&n.displayFormat?n.displayFormat:""},e.prototype.getDefaultOperatorForAttr=function(t){var e=this.getDefaultOperatorIdForAttr(t);return this.getOperatorById(e)},e.prototype.getOperand=function(t,e,r){var n=new p;e&&e.defaultOperand?(n.copyFrom(e.defaultOperand),n.defValue||(n.defValue=""),n.defText||(n.defText="")):(n.kind=s.Scalar,n.dataType=t.dataType,n.defValue="",n.defText="",n.editor=null);var i=n;return i.dataType===o.g.Unknown&&t&&(i.dataType=t.dataType),e&&r>=0&&e.operands&&e.operands[r-1]&&(i=o.P6.assign(i,e.operands[r-1])),i.editor||(n.editor?i.editor=n.editor:n.kind===s.Query?i.editor.tag=v.SubQuery:t&&t.defaultEditor?i.editor=t.defaultEditor:i.dataType===o.g.Date||i.dataType===o.g.DateTime||i.dataType===o.g.Time?i.editor.tag=v.DateTime:i.editor.tag=v.Edit),i},e.prototype.getAggrFunctions=function(){return this.aggrFunctions},e.prototype.isDateMacro=function(t,e){var r=t.match(/\${{?(.*?)}?}/);if(null!=r){var n=r[1];if(o.P6.indexOfArrayItem(this.dateMacros,n)>=0)return e&&e(n),!0}return!1},e.prototype.isTimeMacro=function(t,e){var r=t.match(/\${{?(.*?)}?}/);if(null!=r){var n=r[1];if(o.P6.indexOfArrayItem(this.timeMacros,n)>=0)return e&&e(n),!0}return!1},e.prototype.getDateMacroValue=function(t){var e=new Date;return this.isDateMacro(t,(function(t){switch(t){case"Today":break;case"Yesterday":e.setDate(e.getDate()-1);break;case"Tomorrow":e.setDate(e.getDate()+1);break;case"FirstDayOfMonth":e.setDate(1);break;case"LastDayOfMonth":e.setMonth(e.getMonth()+1,0);break;case"FirstDayOfPrevWeek":r=0==(r=e.getDay())?1:8-r,e.setDate(e.getDate()-r);break;case"FirstDayOfWeek":r=0==(r=e.getDay())?6:r-1,e.setDate(e.getDate()-r);break;case"FirstDayOfYear":e.setMonth(0,1);break;case"FirstDayOfNextWeek":var r;r=0==(r=e.getDay())?1:8-r,e.setDate(e.getDate()+r);break;case"FirstDayOfNextMonth":e.setMonth(e.getMonth()+1,1);break;case"FirstDayOfPrevMonth":e.setMonth(e.getMonth()-1,1);break;case"FirstDayOfPrevYear":e.setFullYear(e.getFullYear()-1,0,1);break;case"FirstDayOfNextYear":e.setFullYear(e.getFullYear()+1,0,1)}}))?e:null},e.prototype.getDateOrMacroValue=function(t){var e=this.getDateMacroValue(t);return e||t},e.prototype.getTimeMacroValue=function(t){var e=new Date;return this.isDateMacro(t,(function(t){switch(t){case"Now":break;case"HourStart":e.setMinutes(0,0,0);break;case"Midnight":e.setHours(0,0,0,0);break;case"Noon":e.setHours(12,0,0,0)}}))?e:null},e.prototype.getTimeOrMacroValue=function(t){var e=this.getTimeMacroValue(t);return e||t},e.prototype.getAllDateMacros=function(){return this.dateMacros},e.prototype.getAllTimeMacros=function(){return this.timeMacros},e}(o.U4),w=function(){function t(t){var e=this;this.parent=t,this.tag=d.Constant,this.kind=s.Scalar,this.dataType=o.g.Unknown,this._value="",this.distinct=!1,this._isDefaultValue=!1,this.getText=function(){return e.text||e._value},this.args=new Array}return t.prototype.getParent=function(){return this.parent},t.prototype.getModel=function(){return this.parent.getQuery().getModel()},t.prototype.loadFromData=function(e,r){if(r)if(this.tag=r.tag,r.val?(this._value=r.val,this.text=r.txt):r.id&&(this.kind=s.Attribute,this._value=r.id,this.text=r.txt),void 0!==r.dtype&&(this.dataType=r.dtype),this.tag==d.EntityAttribute||this.tag==d.ParentEntityAttribute)this.kind=s.Attribute;else{if(void 0!==r.kind&&(this.kind=r.kind),r.query&&(this.subQuery=this.parent.getQuery().createSubQuery(),this.subQuery.loadFromDataOrJson(r.query)),void 0!==r.distinct&&(this.distinct=r.distinct),r.func&&(this.func=r.func,r.args))for(var o=0;o<r.args.length;o++){var n=new t(this.parent);n.loadFromData(e,r.args[o]),this.args.push(n)}r.sql&&(this.sql=r.sql,this.baseAttrId=r.baseAttrId)}},t.prototype.saveToData=function(){var t={tag:this.tag};if(t.dtype=this.dataType,this.tag==d.EntityAttribute||this.tag==d.ParentEntityAttribute)this._value&&(t.id=this._value,t.val=this._value),this.text&&(t.txt=this.text);else{if(this.subQuery&&(t.query=this.subQuery.toJSONData()),void 0!==this.kind&&(t.kind=this.kind),this._value&&(t.val=this._value),this.text&&(t.txt=this.text),this.distinct&&(t.distinct=this.distinct),this.func){t.func=this.func,t.args=[];for(var e=0;e<this.args.length;e++)t.args.push(this.args[e].saveToData())}this.sql&&(t.sql=this.sql,t.baseAttrId=this.baseAttrId)}return t},t.prototype.getIndex=function(){return this.parent.getExpressionIndex(this)},Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),t.prototype.setValue=function(t,e){void 0===e&&(e=!1),this.setContent(t,void 0,e)},t.prototype.setContent=function(t,e,r){void 0===r&&(r=!1);var o=this.value;if(this.kind==s.Attribute&&t){var n=this.getModel().getAttributeById(t);if(!n)throw"No such entity attribute:"+t;this.dataType=n.dataType}this._value=t,void 0!==e?this.text=e:void 0!==this.text&&(this.text=t),this._isDefaultValue=!1,r||this.parent.expressionChanged(this,o)},t.prototype.isEmpty=function(){return!(this.text||this._value)},t.prototype.hasText=function(){return this.text&&this.text.length>0},t.prototype.tryCopyValueFrom=function(t){if(this.kind==t.kind){if(this.dataType==t.dataType)this.setContent(t.value.length?t.value:this._value,t.text&&t.text.length?t.text:this.text,!0);else{var r=e.convertValue(t.value,t.dataType,this.dataType);this.setContent(r.length?r:this._value,t.text&&t.text.length?t.text:this.text,!0)}this.subQuery=t.subQuery,this.sql=t.sql,this.baseAttrId=t.baseAttrId}else this._isDefaultValue||(this.setContent("","",!0),this.subQuery=null,this.sql=null,this.baseAttrId=null)},t}();!function(t){t[t.Conditions=1]="Conditions",t[t.Columns=2]="Columns",t[t.SortingColumns=4]="SortingColumns",t[t.Properties=32]="Properties",t[t.ExtraData=64]="ExtraData",t[t.Facets=128]="Facets",t[t.Aggregation=256]="Aggregation",t[t.All=511]="All"}(x||(x={})),function(t){t[t.Add=1]="Add",t[t.Modify=2]="Modify",t[t.Delete=4]="Delete",t[t.Activate=8]="Activate",t[t.All=127]="All"}(b||(b={})),function(t){t[t.None=0]="None",t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(E||(E={}));var S,D,A=function(){function t(t,e){void 0===e&&(e=!1),this.query=t,this.justsorted=e,this.enabled=!0,this.params=[],this._isHidden=!1,this.query=t,this._id=o.P6.generateId("col"),this.caption="",this._sorting=E.None,this._sortIndex=-1,this.expr=new w(this),this.blockId="",this.justsorted=e}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sorting",{get:function(){return this.query?this.query.getColumnSorting(this):this._sorting},set:function(t){this.query?this.query.setColumnSorting(this,t):this._sorting=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sortIndex",{get:function(){return this.query?this.query.getColumnSortIndex(this):this._sortIndex},set:function(t){this.query?this.query.setColumnSortIndex(this,t):this._sortIndex=t},enumerable:!1,configurable:!0}),t.prototype.getModel=function(){return this.query.getModel()},t.prototype.getQuery=function(){return this.query},t.prototype.isReadOnly=function(){return!1},t.prototype.isJustSorted=function(){return this.justsorted},t.prototype.setReadOnly=function(t){},t.prototype.isHidden=function(){return this._isHidden},t.prototype.setHidden=function(t){this._isHidden=t},t.prototype.getDataType=function(){if(this.expr.dataType===o.g.Unknown){var t=null;if(this.expr.func){if("COUNT"==this.expr.func||"CNTDST"==this.expr.func)return o.g.Int64;t=this.expr.args[0].value}else t=this.expr.value;var e=this.query.getModel().getAttributeById(t);if(e)return e.dataType}return this.expr.dataType},t.prototype.loadFromData=function(t,e){e&&(e.id&&(this._id=e.id),this.caption=e.cptn,void 0!==e.srt&&(this._sorting=e.srt,this._sortIndex=void 0!==e.srtidx?e.srtidx:-1),!1===e.enabled&&(this.enabled=e.enabled),this.expr.loadFromData(t,e.expr),this.blockId=e.blockId,this.displayFormat=e.dfmt,this.groupFooterColumnTemlate=e.gfct,e.hidden&&this.setHidden(!0))},t.prototype.saveToData=function(){var t={};return t.id=this._id,void 0!==this.caption&&(t.cptn=this.caption),this.sorting!=E.None&&(t.srt=this.sorting,t.srtidx=this.sortIndex),t.expr=this.expr.saveToData(),this.blockId&&(t.blockId=this.blockId),!1===this.enabled&&(t.enabled=this.enabled),t.dfmt=this.displayFormat,t.gfct=this.groupFooterColumnTemlate,this.isHidden()&&(t.hidden=!0),t},t.prototype.fireChangedEvent=function(){this.query.fireChangedEvent({part:this.justsorted?x.SortingColumns:x.Columns,action:b.Modify,changee:this})},t.prototype.getExpressionIndex=function(t){return 0},t.prototype.expressionChanged=function(t,e){},t}();!function(t){t[t.Unknown=0]="Unknown",t[t.Simple=1]="Simple",t[t.Group=51]="Group"}(S||(S={})),function(t){t[t.EntityAttr=2]="EntityAttr",t[t.Operator=4]="Operator",t[t.Value=8]="Value",t[t.All=14]="All"}(D||(D={}));var _,O,F=function(){function e(e,r){this.query=e,this.linkType=t.All,this.parent=null,this._id=o.P6.generateId("cond"),this.justAdded=!1,this.tag=r||S.Unknown,this.enabled=!0,this.operatorId="",this.blockId="",this.expressions=new Array,this.conditions=new Array}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled&&(!this.getParent()||this.getParent().enabled)},set:function(t){this._enabled=t&&(!this.getParent()||this.getParent().enabled),this.conditions&&this.conditions.forEach((function(e){e.enabled=t}))},enumerable:!1,configurable:!0}),e.prototype.getQuery=function(){return this.query},e.prototype.getModel=function(){return this.query.getModel()},e.prototype.getParent=function(){return this.parent},e.prototype.setParent=function(t){this.parent=t},e.prototype.getConditions=function(){return this.conditions},e.prototype.isEmpty=function(){return 0===this.conditions.length},e.prototype.isGroup=function(){return this.tag==S.Group||null==this.parent},e.prototype.getLevel=function(){var t=this.getParent();return t?t.getLevel()+1:0},e.prototype.isReadOnly=function(){return!1},e.prototype.setReadOnly=function(t){},e.prototype.isParameterized=function(){return!1},e.prototype.setParameterized=function(t){},e.prototype.isInJoin=function(){return!1},e.prototype.setInJoin=function(t){},e.prototype.clearConditions=function(){this.conditions=[]},e.prototype.addCondition=function(t){return t.setParent(this),this.conditions.push(t)},e.prototype.removeConditionAt=function(t){this.conditions.splice(t,1)},e.prototype.loadFromData=function(t,e){if(e){if(this.tag=e.tag,this.tag||(this.tag=!this.parent||this.conditions.length>0?S.Group:S.Simple),void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.disabled&&(this.enabled=!e.disabled),this.tag==S.Simple&&(this.operatorId=e.op,e.exprs))for(var r=0;r<e.exprs.length;r++){var o=new w(this);o.loadFromData(t,e.exprs[r]),this.expressions.push(o)}this.linkType=e.linking}},e.prototype.saveToData=function(){var t={};if(t.tag=this.tag,this.enabled||(t.enabled=this.enabled),this.tag==S.Simple){t.op=this.operatorId,t.exprs=[];for(var e=0;e<this.expressions.length;e++)t.exprs.push(this.expressions[e].saveToData())}return this.tag==S.Group&&(t.linking=this.linkType),t},e.prototype.fireChangedEvent=function(t){void 0===t&&(t=D.All),this.query.fireChangedEvent({part:x.Conditions,action:b.Modify,changee:this,condPart:t})},e.prototype.getExpressionIndex=function(t){return this.expressions.indexOf(t,0)},e.prototype.expressionChanged=function(t,e){0==t.getIndex()&&t.tag==d.EntityAttribute&&this.tuneOperatorForAttr(t.value)},e.prototype.getOperatorId=function(){return this.operatorId},e.prototype.setOperatorId=function(t,e){void 0===e&&(e=!1);var r=this.operatorId;if(this.operatorId=t,!e){var o=this.getModel(),n=o.getOperatorById(t),i=this.expressions[0].value,s=o.getAttributeById(i);this.tuneValueExpressions(s,n,s.id,r)}},e.prototype.tuneOperatorForAttr=function(t){var e=this.getModel(),r=this.expressions[0].value,o=e.getAttributeById(r);if(null!=o){var n=this.getModel().getDefaultOperatorForAttr(o),i=this.operatorId;this.operatorId=n.id,this.tuneValueExpressions(o,n,t,i)}},e.prototype.tuneValueExpressions=function(t,e,r,n){var i=this.getModel();if(e){var s=this.expressions.length,a=(r&&i.getAttributeById(r),null);if(n&&(a=i.getOperatorById(n)),a&&a.paramCount==e.paramCount){for(var u=1;u<e.paramCount;){var l=i.getOperand(t,a,u);(g=i.getOperand(t,e,u)).dataType==o.g.Unknown&&(g.dataType=t.dataType);var d=g.editor&&g.editor.tag!==o.mb.Unknown?g.editor:t.defaultEditor&&t.defaultEditor.tag!==o.mb.Unknown?t.defaultEditor:new c;if(u>=s){var h=this.createValueExpr(g);this.expressions.push(h)}else{var p=this.expressions[u],f=this.createValueExpr(g);this.areCompitableEditors(l.editor,d)&&f.tryCopyValueFrom(p),this.expressions[u]=f}u++}s>u&&this.expressions.splice(u,s-u)}else{this.expressions.splice(1,this.expressions.length-1);for(u=1;u<e.paramCount;u++){var g;(g=i.getOperand(t,e,u)).dataType==o.g.Unknown&&(g.dataType=t.dataType);h=this.createValueExpr(g);this.expressions.push(h)}}}},e.prototype.areCompitableEditors=function(t,e){return e.tag!=v.CustomList&&e.tag!=v.List&&e.tag!=v.SqlList&&e.tag!=o.mb.Unknown},e.prototype.addExpressionByOperand=function(t,e){void 0===e&&(e=null);var r=this.createValueExpr(t,e);return this.expressions.push(r),r},e.prototype.createValueExpr=function(t,e){void 0===e&&(e=null);var r=null==e,o=e||t.defValue,n=e||t.defText,i=new w(this);if(t.kind===s.Query)i.tag=d.Query,i.dataType=t.dataType,i.kind=t.kind,i.setContent(o,n,!0);else if(t.kind===s.Attribute){if(!r){var a=this.getModel().getFirstAttributeByFilter((function(e){return 1==e.useInConditions&&(!t.dataType||e.dataType==t.dataType)}));o=a?a.id:null}i.tag=d.EntityAttribute,i.kind=t.kind,i.dataType=t.dataType,i.setContent(o,n,!0)}else r&&(o=t.defValue&&""!=t.defValue?t.defValue:t.editor&&t.editor.defValue?t.editor.defValue:"",t.editor&&(n=t.editor.getValueText(o))),i.tag=d.Constant,i.dataType=t.dataType,i.kind=t.kind,i.setContent(o,n,!0),i._isDefaultValue=r;return i},e}(),q=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),M=function(t){function e(r){var o=t.call(this,r)||this;return Error.captureStackTrace&&Error.captureStackTrace(o,e),o.name="InvalidQueryError",o}return q(e,t),e}(Error),P=function(){function r(t,e,r){var n=this;this.extraData={},this.innerData={},this.isNewbie=!0,this._isModified=!1,this._enableAggregation=!1,this.parentQuery=null,this.drillDowns=[],this.syncSortOrderWithColumnsOrder=!0,r&&(this.context=r.context,this.context&&(this.syncSortOrderWithColumnsOrder=this.context.options.syncSortOrderWithColumnsOrder)),this.eventEmitter=new o.vp(this),this.root=new F(this,S.Group),this.extraConditions=new F(this,S.Group),this.columns=new Array,this.sortedColumns=new Array,this.id||this.regenerateId(),this.setDefaultName(),this.description="",this.model=t||new I,e&&this.loadFromData(e),this.attributeExprTag=r&&r.attrTag||d.EntityAttribute,this.clientListRequestHandler=r?r.clientListRequestHandler:new Array,this.serverListRequestHandler=r?r.serverListRequestHandler:new Array,this.timezoneOffset=(new Date).getTimezoneOffset(),this.aggrSettings=new o.$h(this),r&&(this.parentQuery=r.parent),this.addChangedCallback((function(t){t.data&&(t.data.part&x.Columns)>0&&!t.data.aggregation&&n._enableAggregation&&n.updateAggregationSettings()&&n.fireChangedEvent({part:x.Aggregation})}))}return r.prototype.isModified=function(){return this._isModified},r.prototype.resetModified=function(){this._isModified=!1},Object.defineProperty(r.prototype,"enableAggregation",{get:function(){return this._enableAggregation},set:function(t){var e=this._enableAggregation;if(this._enableAggregation=t,!e&&t){this.processQueryForAggregation();this.columns.filter((function(t){return t.enabled&&t.expr.tag==d.AggregateFunction}))}this._enableAggregation||this.aggrSettings.clear()},enumerable:!1,configurable:!0}),r.prototype.updateAggregationSettings=function(){for(var t=!1,e=this.getAggregationSettings(),r=e.groups.length-1;r>=0;r--){for(var o=e.groups[r],n=function(e){var r=o.columns[e];i.columns.find((function(t){return t.id===r}))||(o.columns.splice(e,1),t=!0)},i=this,s=o.columns.length-1;s>=0;s--)n(s);0==o.columns.length&&e.groups.slice(r,1)}var a=e.getAggregates(),u=function(e){var r=a[e];l.columns.find((function(t){return t.id===r.colId}))||(a.splice(e,1),t=!0)},l=this;for(r=a.length-1;r>=0;r--)u(r);return t},r.prototype.createSubQuery=function(){return new r(this.model,null,{context:this.context})},r.prototype.useAggregation=function(t,e){if(void 0===e&&(e=!1),this.aggrSettings.clear(),t(this.aggrSettings),this.enableAggregation)this.processQueryForAggregation(e);else if(!e)return void console.warn("Aggregation is turned off. Turn it on with query.enableAggregation = true")},r.prototype.useDefaultAggregation=function(){var t=this;this._enableAggregation=!0,this.useAggregation((function(e){var r=t.columns.filter((function(t){return t.enabled&&t.expr.tag==d.AggregateFunction}));if(r.length){for(var n=t.columns.filter((function(t){return t.enabled&&t.expr.tag==d.EntityAttribute})),i=[],s=0,a=r;s<a.length;s++){var u=a[s];i.push({id:u.id,func:u.expr.func}),t.changeColumnType(u,d.EntityAttribute)}for(var l=0,c=i;l<c.length;l++){var h=c[l];e.addAggregateColumn(h.id,h.func)}for(var p=0,f=n;p<f.length;p++){u=f[p];e.addGroup({columns:[u.id],name:u.caption})}e.addGrandTotals(),t.fireChangedEvent({part:x.Columns,wasModified:!1})}else{var g=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==d.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===o.g.Currency}))[0],y=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==d.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===o.g.String}))[0];if(!g&&!e.hasAggregates()||!y)return;e.addGrandTotals().addAggregateColumn(g.id,"SUM").addGroup({columns:[y.id],name:"Default"})}}))},r.prototype.processQueryForAggregation=function(t){var e=this;void 0===t&&(t=!1);var r=this.getAggregationSettings().getGroups();if(r.length>0){for(var o=r[r.length-1].columns,n=[],i=[],s=0,a=this.getColumns();s<a.length;s++){var u=a[s];o.indexOf(u.id)>=0?n.push(u):this.getColumnSorting(u)!=E.None&&i.push(u)}var l=0;n.forEach((function(t){e.getColumnSorting(t)==E.None&&e.setColumnSorting(t,E.Ascending),e.setColumnSortIndex(t,l++)})),i.forEach((function(t){e.setColumnSortIndex(t,l++)})),t||this.fireChangedEvent({part:x.Columns,aggregation:!0,wasModified:!1})}},r.prototype.getAggregationSettings=function(){return this.aggrSettings},r.prototype.getColumnIds=function(t,e){return e=e||t,this.columns.slice(t,e-t+1).map((function(t){return t.id}))},r.prototype.validateColumns=function(t){for(var e=this.columns.filter((function(t){return t.enabled})).map((function(t){return t.id})),r=-1,o=0,n=t;o<n.length;o++){var i=n[o],s=e.indexOf(i);if(s<0)return!1;if(r>s)return!1;r=s}return!0},r.prototype.validateAggregate=function(t,e){var r=this.columns.filter((function(e){return e.enabled&&e.id===t}))[0],o=this.model.findAggrFunctionById(e);return!(!o||!r||o.appliedTypes.indexOf(r.expr.dataType)<0)},r.prototype.isEx=function(){return!1},r.prototype.reset=function(t){void 0===t&&(t=!0),t&&this.clear(),this.regenerateId(),this.setDefaultName(),this._isModified=!1,this.isNewbie=!0},r.prototype.hasEnabledAggrColumns=function(){return this.columns.filter((function(t){return t.enabled&&t.expr.tag===d.AggregateFunction})).length>0},r.prototype.setDefaultName=function(){return this.setName(o.ag.getText("NewQueryName")),this.getName()},r.prototype.validate=function(t){t=t||{};var e="EntityAttribute isn't declared in the model: ";if(!this.model)throw new M("Model is not declared");if(this.columns)for(var r=0,o=this.columns;r<o.length;r++){var n=o[r];if(n.expr.tag==d.EntityAttribute||n.expr.tag===d.ParentEntityAttribute){if(!this.model.getAttributeById(n.expr.value))throw new M(e+n.expr.value)}else if(n.expr.tag===d.AggregateFunction){if(!this.model.getAttributeById(n.expr.args[0].value))throw new M(e+n.expr.args[0].value)}else if(n.expr.tag!==d.CustomSql)throw new M("The expression has wrond tag: "+n.expr.tag)}this.root&&this.root.getConditions()&&this.validateConditionGroup(this.root,t)},r.prototype.getAggregatedColumns=function(){return this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===d.AggregateFunction}))},r.prototype.tryValidate=function(t){try{return this.validate(t),!0}catch(t){if(t instanceof M)return!1;throw t}},r.prototype.validateConditionGroup=function(t,e){if(t.isGroup())for(var r=0,n=t.getConditions();r<n.length;r++){var i=n[r];i.enabled&&this.validateConditionGroup(i,e)}else if(t.expressions[0].tag===d.EntityAttribute){var a=t.expressions[0].value;if(!this.model.getAttributeById(a))throw new M("EntityAttribute isn't declared in the model: "+a);if(!e.checkExpressions)return;for(var u=1;u<t.expressions.length;u++){var l=t.expressions[u];if(l.tag===d.Constant&&o.P6.isNumericType(l.dataType)){if(!l.value)continue;for(var c=0,h=l.kind===s.List?l.value.split(/\s*,\s*/):[l.value];c<h.length;c++){var p=h[c],f=+p;if(isNaN(f))throw new M("Expression constant is NaN in condition:"+t.id);if(o.P6.isIntType(l.dataType)&&f!=parseInt(p,10))throw new M("Expression constant is wrong interger in condition: "+t.id)}}}}},r.prototype.loadFromDataOrJson=function(t,e){t&&("string"==typeof t?this.loadFromJson(t,e):this.loadFromData(t,e))},r.prototype.loadFromJson=function(t,e){var r=JSON.parse(t);this.loadFromData(r,e)},r.prototype.loadFromData=function(t,e){var r=this;e=o.P6.assign({changeStatus:!0,validate:!0},e||{});if(this.clear(),this.clearDrillDowns(),t){if(this.id=t.id,this.root.loadFromData(this.model,t.root),t.root&&t.root.conds)for(var n=0;n<t.root.conds.length;n++){var i=t.root.conds[n];if(!i.conds||this.isEx()){var s=this.createCondition();s.loadFromData(this.model,i),this.root.addCondition(s)}else console.error("Community version doesn't support working with groups.")}if(this.name=t.name,this.description=t.desc,this.sortedColumns=[],t.justsortcols)for(n=0;n<t.justsortcols.length;n++){(a=this.createColumn(!0)).loadFromData(this.model,t.justsortcols[n]),this.addColumnToSorted(a)}if(t.cols)for(n=0;n<t.cols.length;n++){var a;(a=this.createColumn()).loadFromData(this.model,t.cols[n]),this.columns.push(a),a._sorting!=E.None&&this.addColumnToSorted(a)}if(this.sortedColumns.sort((function(t,e){return t._sortIndex-e._sortIndex})),this.fixupSortingIndices(),t.extraData&&(this.extraData=t.extraData),this.innerData=t.innerData||this.innerData,this.innerData&&this.innerData.aggr&&(this._enableAggregation=this.innerData.aggr.enabled||!1,this.useAggregation((function(t){t.loadFromData(r.innerData.aggr)}),!0)),t.dds&&t.dds.length)for(var u=0,l=t.dds;u<l.length;u++){var c=l[u];this.addDrillDown().loadFromData(c)}}e.changeStatus&&(this.isNewbie=!1,this._isModified=!1),e.validate&&this.validate()},r.prototype.addDrillDown=function(){var t=this.model.createQuery();return t.parentQuery=this,this.drillDowns.push(t),t},r.prototype.getDrillDowns=function(){return this.drillDowns},r.prototype.getParentQuery=function(){return this.parentQuery},r.prototype.findColumnById=function(t){for(var e=0,r=this.columns;e<r.length;e++){var o=r[e];if(o.id===t)return o}return null},r.prototype.getModel=function(){return this.model},r.prototype.setModel=function(t){this.model=t},r.prototype.loadModelData=function(t){this.model.setData(t)},r.prototype.toJSON=function(){return JSON.stringify(this.toJSONData())},r.prototype.toJSONData=function(){var t=this;this.fixupSortingIndices();var e={modelId:this.model?this.model.getId():null,modelName:this.model?this.model.getName():null};e.id=this.id,e.name=this.name,this.description&&(e.desc=this.description),e.cols=[];for(var r=0;r<this.columns.length;r++)e.cols.push(this.columns[r].saveToData());e.justsortcols=[],this.sortedColumns.forEach((function(t){t.isJustSorted()&&e.justsortcols.push(t.saveToData())})),this.extraData&&(e.extraData=this.extraData),this.innerData&&(e.innerData=this.innerData,e.innerData.aggr=this.aggrSettings.saveToData(),e.innerData.aggr.enabled=this._enableAggregation);var n=function(e){var r=e.saveToData();r.conds=[];for(var o=e.getConditions(),n=0;n<o.length;n++)!o[n].isGroup()||t.isEx()?r.conds.push(o[n].saveToData()):console.error("Community version doesn't support working with groups.");return r};if(e.root=n(this.root),e.extraConds=n(this.extraConditions),this.drillDowns.length>0){e.dds=[];for(var i=0,s=this.drillDowns;i<s.length;i++){var a=s[i];e.dds.push(a.toJSONData())}}return e.timezoneOffset=this.timezoneOffset,e.locale=o.ag.getCurrentLocale(),e},r.prototype.isEmptyConditions=function(){return this.root.isEmpty()},r.prototype.isEmptyColumns=function(){return!this.columns||0===this.columns.length},r.prototype.isEmpty=function(){return this.isEmptyColumns()&&this.isEmptyConditions()},r.prototype.clear=function(){this._enableAggregation=!1,this.aggrSettings.clear(),this.clearColumns(),this.clearConditions(),this.clearExtraConditions(),this.innerData={},this.extraData={}},r.prototype.clearColumns=function(){this.columns=[],this.sortedColumns=[]},r.prototype.clearConditions=function(){this.root.clearConditions(),this.root.linkType=t.All,this.root.enabled=!0},r.prototype.clearExtraConditions=function(){this.extraConditions.clearConditions()},r.prototype.clearDrillDowns=function(){this.drillDowns=[]},r.prototype.getId=function(){return this.id},r.prototype.setId=function(t){this.id=t},r.prototype.regenerateId=function(){this.id=o.P6.generateId("quer")},r.prototype.getName=function(){return this.name},r.prototype.setName=function(t){this.name=t},r.prototype.getDescription=function(){return this.description},r.prototype.setDescription=function(t){this.description=t},r.prototype.getColumns=function(){return this.columns},r.prototype.getUsedInTotalsColumns=function(){if(0===this.getAggregatedColumns().length)return[];var t=this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===d.EntityAttribute}));return t.length&&t.pop(),t},r.prototype.addColumnToSorted=function(t){var e=JSON.stringify(t.expr.saveToData()),r=!0;this.sortedColumns.forEach((function(t){JSON.stringify(t.expr.saveToData())===e&&(r=!1)})),r&&this.sortedColumns.push(t)},r.prototype.getJustSortedColumns=function(){return this.sortedColumns.filter((function(t){return t.isJustSorted()}))},r.prototype.getSortedColumns=function(){return this.sortedColumns},r.prototype.getColumnSortIndex=function(t){return this.sortedColumns.indexOf(t)},r.prototype.setColumnSortIndex=function(t,e){if(!(e<0)){var r=this.getColumnSortIndex(t);r<0&&(this.addColumnToSorted(t),r=this.sortedColumns.length-1),o.P6.moveArrayItem(this.sortedColumns,r,e),this.fixupSortingIndices(),this.fireColumnsChangedEvent(b.All)}},r.prototype.getColumnSorting=function(t){return this.getColumnSortIndex(t)>=0?t._sorting!=E.None?t._sorting:E.Ascending:E.None},r.prototype.setColumnSorting=function(t,e){var r=this.getColumnSortIndex(t);t._sorting=e,r>=0?e==E.None&&(o.P6.removeArrayItem(this.sortedColumns,t),this.fixupSortingIndices()):e!=E.None&&(this.addColumnToSorted(t),this.fixupSortingIndices()),this.adjustColumnsSorting(),this.fireColumnsChangedEvent(b.Modify,t,t.isJustSorted())},r.prototype.fixupSortingIndices=function(){this.sortedColumns.forEach((function(t,e){t._sortIndex=e}))},r.prototype.adjustColumnsSorting=function(){var t=this;if(this.syncSortOrderWithColumnsOrder&&!(this.getJustSortedColumns().length>0)){var e=0;this.columns.forEach((function(r){if(r.sorting!=E.None){var n=t.getColumnSortIndex(r);n>=0&&(o.P6.moveArrayItem(t.sortedColumns,n,e),e++)}})),this.fixupSortingIndices()}},r.prototype.createColumn=function(t){return void 0===t&&(t=!1),new A(this,t)},r.prototype.getColumnById=function(t){return o.P6.findItemById(this.columns,t)},r.prototype.addColumn=function(t,e){var r;if(t.column)r=t.column;else{r=this.createColumn(t.justsorted);var n=void 0;if(t.attribute)n=t.attribute;else{if(!t.attributeId)throw new Error("Not enought data for addColumn operation. Need attribute or attributeId");if(!(n=this.model.getAttributeById(t.attributeId)))throw new Error("Incorrect attribute id (".concat(t.attributeId,"): addColumn"))}if(!n.useInResult&&(n.lookupAttr&&(n=this.model.getAttributeById(n.lookupAttr)),!n||!n.useInResult))throw new Error("Can't use this attribute for a column");if(t.aggrFuncId&&t.cusomtSql&&console.warn("Column cannot be created using aggrFuncId and customSql at the same time. cusomSql will be used."),t.cusomtSql)r.caption="Custom SQL Column",r.expr.tag=d.CustomSql,r.expr.baseAttrId=n.id,r.expr.sql=t.cusomtSql,r.expr.kind=s.Query,r.expr.dataType=o.g.Unknown;else if(t.aggrFuncId){var i=t.aggrFuncId;r.caption=n.caption+" "+this.model.getAggrFunctionCaption(t.aggrFuncId),r.expr.tag=d.AggregateFunction,r.expr.func=t.aggrFuncId,r.expr.kind=s.Scalar,r.expr.dataType="COUNT"==i||"CNTDST"==i?4:n.dataType,r.expr.distinct=!1;var a=new w(r);a.setValue(n.id,!0),a.tag=d.EntityAttribute,a.dataType=n.dataType,r.expr.args.push(a)}else r.caption=n.caption,r.expr.setValue(n.id,!0),r.expr.tag=d.EntityAttribute,r.expr.dataType=n.dataType;r.caption=t.caption||r.caption,r._sorting=t.sorting||E.None,r._sortIndex=t.sortIndex||-1,r.enabled=o.P6.getIfDefined(t.enabled,!0),r.setReadOnly(o.P6.getIfDefined(t.readonly,!1))}var u=t.justsorted||t.column&&t.column.isJustSorted();return u||(t.index&&t.index>=0&&t.index<this.columns.length?this.columns.splice(t.index,0,r):this.columns.push(r)),this.setColumnSorting(r,r._sorting),this.fireColumnsChangedEvent(b.Add,r,u),r},r.prototype.addColumnObj=function(t,e,r){var o=this,n=this.columns;void 0===t.length?("number"==typeof e?n.splice(e,0,t):n.push(t),t.sorting!=E.None&&this.addColumnToSorted(t),this.fixupSortingIndices()):("number"==typeof e?n.push.apply(n,[e,0].concat(t)):n.push.apply(n,[].concat(t)),t.forEach((function(t){t.sorting!=E.None&&o.addColumnToSorted(t)})),this.fixupSortingIndices())},r.prototype.changeColumnType=function(t,e,r){if(!t.isJustSorted())if(r=r||{},t.caption=void 0!==r.caption?r.caption:"",e===d.AggregateFunction){if(!r.funcId)throw Error('"funcId" argument is not defined');if(t.expr.tag==d.AggregateFunction)return void(t.expr.func=r.funcId);(u=new w(t)).tag=d.AggregateFunction,u.func=r.funcId,u.distinct=!1,u.dataType="COUNT"==r.funcId||"CNTDST"==r.funcId?4:t.expr.dataType;var n=new w(t);n.loadFromData(this.model,t.expr.saveToData()),u.args.push(n),t.expr=u}else if(e===d.CustomSql){var i=t.expr.tag==d.AggregateFunction?t.expr.args[0].value:t.expr.value,s="";this.model&&(s=this.model.getAttributeById(i).expr);var a=new w(t);a.tag=d.CustomSql,a.dataType=o.g.String,a.sql=s,a.baseAttrId=i,t.expr=a}else if(e===d.EntityAttribute){if(t.expr.tag===d.EntityAttribute||t.expr.tag===d.ParentEntityAttribute)return;var u,l=t.expr.tag===d.CustomSql?t.expr.baseAttrId:t.expr.args[0].value,c=this.model.getAttributeById(l);(u=new w(t)).tag=d.EntityAttribute,u.dataType=null!=c?c.dataType:o.g.Unknown,u.setValue(l,!0),t.expr=u}},r.prototype.moveColumn=function(t,e){var r=this.getColumns();o.P6.moveArrayItem(r,t,e),this.adjustColumnsSorting()},r.prototype.removeColumn=function(t,e){o.P6.removeArrayItem(this.columns,t),o.P6.removeArrayItem(this.sortedColumns,t)},r.prototype.addConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},r.prototype.addExtraConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},r.prototype.createCondition=function(t){return void 0===t&&(t=S.Simple),new F(this,t)},r.prototype.addSimpleCondition=function(t){var e=t.parent||this.getRootCondition(),r=this.getModel();if(!r)return null;if(!t.attribute&&!t.attributeId)throw new Error("Either `attribute` or `attributeId` parameter must have a value");if(!t.attribute&&(t.attribute=r.getAttributeById(t.attributeId),!t.attribute))throw new Error("Could not find this attribute: "+t.attributeId);!t.operator&&t.operatorId&&(t.operator=r.getOperatorById(t.operatorId)),t.operator||(t.operator=r.getDefaultOperatorForAttr(t.attribute));var n=this.createSimpleConditionObject(t.attribute,t.operator,t.value);return e.addCondition(n),n.enabled=o.P6.getIfDefined(t.enabled,!0),n.setReadOnly(o.P6.getIfDefined(t.readonly,!1)),n},r.prototype.addSimpleExtraCondition=function(t){return t.parent=t.parent||this.extraConditions,this.addSimpleCondition(t)},r.prototype.createSimpleConditionObject=function(t,e,r){if(!t||!t.useInConditions)throw"Can't add a condition with such attribute: "+(t?t.caption:"NULL");var n=this.createCondition(S.Simple);n.setOperatorId(e.id,!0);var i=new w(n);i.setValue(t.id,!0),i.tag=this.attributeExprTag,i.kind=s.Attribute,i.dataType=t.dataType,n.expressions.push(i);var a=this.getModel(),u=e.paramCount,l=o.P6.fillArray(new Array(u-1),null);null!=r&&(Array.isArray(r)?o.P6.copyArrayTo(r,l):u>0&&(l[0]=r));for(var c=l.length,d=0;d<c;d++){var h=a.getOperand(t,e,d+1);n.addExpressionByOperand(h,l[d])}return n},r.prototype.removeColumns=function(t,e){var r=t.filter((function(t){return t.isJustSorted()})),o=t.filter((function(t){return!t.isJustSorted()}));function n(t,e){for(var r=e.length,o=0;o<r;o++){var n=t.indexOf(e[o]);n>=0&&t.splice(n,1)}}o.length>0&&(n(this.getColumns(),o),n(this.sortedColumns,o)),r.length>0&&n(this.sortedColumns,r),this.fixupSortingIndices()},r.prototype.fireProcessEvent=function(t){this.eventEmitter.fire("query.process",t)},r.prototype.fireChangedEvent=function(t,e,r){t=t||{part:x.All},void 0===e&&void 0===r||(t.postpone=e||0,t.wasModified=r,console.warn("Method with 'postpone' and 'wasModified' args is deprecated. Pass params in data object")),this._isModified=void 0===t.wasModified||t.wasModified;var o=t||{part:x.All};this.eventEmitter.fire("query.change",o,t.postpone||0)},r.prototype.fireColumnsChangedEvent=function(t,e,r){void 0===r&&(r=!1),this.fireChangedEvent({part:r?x.SortingColumns:x.Columns,action:t,changee:e})},r.prototype.fireConditionsChangedEvent=function(t,e){this.fireChangedEvent({part:x.Conditions,action:t,changee:e})},r.prototype.runThroughConditions=function(t){var e=function(r){for(var o=0;o<r.getConditions().length;o++){var n=r.getConditions()[o];n.isGroup()?e(n):t&&t(n)}};e(this.getRootCondition())},r.prototype.getOneValueForAttr=function(t){var e=null;return this.runThroughConditions((function(r){if(r.enabled){var o=r.expressions[0],n=r.getOperatorId();o.value!=t||!r.expressions[1]||"Equal"!=n&&"InList"!=n&&"StartsWith"!=n||(e=r.expressions[1].value)}})),e},r.prototype.getRootCondition=function(){return this.root},r.prototype.addProcessCallback=function(t){return this.eventEmitter.subscribe("query.process",t)},r.prototype.removeProcessCallback=function(t){this.eventEmitter.unsubscribe("query.process",t)},r.prototype.addChangedCallback=function(t){return this.eventEmitter.subscribe("query.change",t)},r.prototype.removeChangedCallback=function(t){this.eventEmitter.unsubscribe("query.change",t)},r.prototype.getConditionsText=function(){var r=this,n=this.getModel();if(!n)return"";var i=function(a){var u,l,c="",h="Conj"+e.linkTypeToStr(a.linkType),p=o.ag.getText(h);for(l=0;l<a.getConditions().length;l++){u="";var f=a.getConditions()[l];if(f.enabled||void 0===f.enabled)if(f.isGroup())(u=i(f))&&(u="("+u+")");else for(var g=f.getOperatorId(),y=n.getOperatorById(g),m=e.parseOperatorFormat(y),v=m.length,x=0;x<v;x++){var b=m[x],E=b.text;if("expression"==b.type){var C=f.expressions[b.index];if(C.kind==s.Attribute||C.tag==d.EntityAttribute){var T=n.getAttributeById(C.value);E=n.getAttributeText(T,"{entity} {attr}")}else if(E=C.getText(),r.model.isDateMacro(E)||r.model.isTimeMacro(E)){var I=E.substring(3,E.length-2);E=o.ag.getText(I)||E}}x>0&&(u+=" "),u+=E}u&&(l>0&&c&&(c+=" "+p+" "),c+=u)}return a.linkType!=t.None&&a.linkType!=t.NotAll||(c="not ( "+c+" )"),c};return i(this.getRootCondition())},r.prototype.getConditionsTextAsHtml=function(){var r=this,n=this.getModel();if(!n)return'<div class="eqjs-query-text"></div>';var i=function(t){if(t.kind==s.Query)return"<".concat(t.getText(),">");if(t.kind==s.List)return"[".concat(t.getText(),"]");if(t.dataType==o.g.String||t.dataType==o.g.Memo||t.dataType==o.g.FixedChar)return""".concat(t.getText(),""");var e=t.getText();if(r.model.isDateMacro(e)||r.model.isTimeMacro(e)){var n=e.substring(3,e.length-2);e=o.ag.getText(n)||e}return e},a=function(r){var u,l,c="",h="Conj"+e.linkTypeToStr(r.linkType),p='<span class="eqjs-query-text-conj">'.concat(o.ag.getText(h),"</span>");for(l=0;l<r.getConditions().length;l++){u="";var f=r.getConditions()[l];if(f.enabled||void 0===f.enabled)if(f.isGroup())(u=a(f))&&(u="("+u+")");else for(var g=f.getOperatorId(),y=n.getOperatorById(g),m=e.parseOperatorFormat(y),v=m.length,x=0;x<v;x++){var b=m[x],E=b.text;if("expression"==b.type){var C=f.expressions[b.index];if(C.kind==s.Attribute||C.tag==d.EntityAttribute){var T=n.getAttributeById(C.value);E='<span class="eqjs-query-text-attr">'.concat(n.getAttributeText(T,"{entity} {attr}"),"</span>")}else E='<span class="eqjs-query-text-expr">'.concat(i(C),"</span>")}else"operator"==b.type&&(E='<span class="eqjs-query-text-op">'.concat(E,"</span>"));x>0&&(u+=" "),u+=E}u&&(l>0&&c&&(c+=" "+p+" "),c+=u)}return r.linkType!=t.None&&r.linkType!=t.NotAll||(c='<span class="eqjs-query-text-conj">not</span> ( '+c+" )"),c};return'<div class="eqjs-query-text">'.concat(a(this.getRootCondition()),"</div>")},r}(),k=function(){function t(t){this.context=t,console.warn("BrowserQueryStorage is used for managing queries")}return t.prototype.init=function(t){var e="eq";t&&t.keyPrefix&&(e=t.keyPrefix),this.queryListKey=e+"-querylist",this.queryKeyPrefix=e},t.prototype.getQueryList=function(t){var e=this;return new Promise((function(t,r){try{var o=localStorage.getItem(e.queryListKey);o&&t(JSON.parse(o)),t([])}catch(t){r(t)}}))},t.prototype.newQuery=function(t){var e=this;return new Promise((function(r,o){var n=new P(e.context.getModel(),null,{context:e.context});n.reset(),n.setDefaultName(),t&&(t.query&&n.loadFromData(t.query.toJSONData()),t.queryId&&n.setId(t.queryId),t.name&&n.setName(t.name),t.description&&n.setDescription(t.description)),e._saveQuery(n),r(n.toJSONData())}))},t.prototype.loadQuery=function(t){var e=this;return new Promise((function(r,o){try{var n=localStorage.getItem(e.queryKeyPrefix+"-"+t.queryId);throw n&&r(JSON.parse(n)),new Error("Query is not found: "+t.queryId)}catch(t){o(t)}}))},t.prototype.saveQuery=function(t){var e=this;return new Promise((function(r,o){try{t.modelId||e.context.getModel().getId();var n=t.query||e.context.getQuery();e._saveQuery(n),r(null)}catch(t){o(t)}}))},t.prototype._saveQuery=function(t){var e=[],r=localStorage.getItem(this.queryListKey);r&&(e=JSON.parse(r));var n=o.P6.findItemById(e,t.getId());n||(n={id:t.getId(),name:t.getName(),text:t.getDescription()},e.push(n)),n.name=t.getName(),n.text=t.getDescription(),localStorage.setItem(this.queryListKey,JSON.stringify(e)),localStorage.setItem(this.queryKeyPrefix+"-"+t.getId(),t.toJSON())},t.prototype.removeQuery=function(t){var e=this;return new Promise((function(r,o){try{t.modelId||e.context.getModel().getId();var n=t.queryId||e.context.getQuery().getId(),i=[],s=localStorage.getItem(e.queryListKey);s&&(i=JSON.parse(s)),i=i.filter((function(t){return t.id!=n})),localStorage.setItem(e.queryListKey,JSON.stringify(i)),localStorage.removeItem(e.queryKeyPrefix+"-"+n),r()}catch(t){o(t)}}))},t}(),L=function(){function t(t){this.context=t,this.modelPromise=null}return t.prototype.init=function(t){},t.prototype.getContext=function(){return this.context},t.prototype.createModelLoadingPromise=function(){var t=this;this.modelPromise=new Promise((function(e,r){t.modelLoadingResolveFunc=e,t.modelLoadingRejectFunc=r}))},t.prototype.getModelPromise=function(){return this.modelPromise||Promise.reject(new Error("Model has been never loaded."))},t.prototype.startModelLoading=function(t){return this.createModelLoadingPromise(),this.sendLoadModelRequest(t),this.modelPromise},t}(),R=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}}(),N=function(t){function e(e){return t.call(this,e)||this}return R(e,t),e.prototype.init=function(){},e.prototype.sendLoadModelRequest=function(t){var e=this,r=this.getContext(),o=r.getServices().getHttpClient(),n=r.resolveEndpoint("GetModel",{modelId:t.modelId});o.get(n).then((function(t){t.model||e.modelLoadingRejectFunc(new Error('Wrong response format for "GetModel" request')),e.modelLoadingResolveFunc(t.model)})).catch((function(t){e.modelLoadingRejectFunc(t)}))},e}(L),Q=function(){function t(t){this.context=t}return t.prototype.fetchData=function(t){var e=t.query||this.context.getQuery(),r=e.getId(),o={options:t.options};void 0!==t.queryId?o.queryId=t.queryId:o.query=e.toJSONData(),t.debug&&(o.debug=t.debug),t.chunk&&(o.chunk=t.chunk),t.data&&(o.data=t.data),void 0!==t.aux&&(o.aux=t.aux);var n=this.context.resolveEndpoint("FetchData",{modelId:e.getModel().getId(),queryId:r});return this.context.getServices().getHttpClient().post(n,o).then((function(t){return t}))},t}(),B=function(){function t(t){this.context=t}return t.prototype.syncQuery=function(t){var e=(t=t||{}).query||this.context.getQuery(),r=t.options||{},o={query:e.toJSONData(),options:r};t.data&&(o.data=t.data);var n=this.context.resolveEndpoint("SyncQuery",{modelId:e.getModel().getId(),queryId:e.getId()});return this.context.getServices().getHttpClient().post(n,o).then((function(t){return t}))},t}(),j=function(){function t(t){this.context=t}return t.prototype.loadValueList=function(t){var e=t.modelId||this.context.getModel().getId(),r=o.P6.assign({modelId:e},t.params).editorId,n=this.context.getServices().getHttpClient(),i=this.context.resolveEndpoint("GetValueList",{modelId:e,listId:r}),s={};return t&&t.params&&t.params.queryParams&&(s=t.params.queryParams),n.get(i,{queryParams:s}).then((function(t){if(t&&t.values)return t.values;throw new Error('Wrong response format. No "values" property')}))},t}(),G=function(){function t(t){this.context=t}return t.prototype.getQueryFile=function(t){var e=t.query||this.context.getQuery(),r=this.context.resolveEndpoint("GetQueryFile",{modelId:e.getModel().getId(),format:t.format||"xml"}),o=this.context.getServices().getHttpClient().post(r,{query:e.toJSONData()}),n=o.getRequest();return o.then((function(e){var r=new Blob([e]),o=n.getXMLHttpRequest().getResponseHeader("Content-Disposition"),i=o?o.match(/filename="(.*)"/)[1]:"query.json";if(t.fileName&&(i=t.fileName+i.substring(i.lastIndexOf("."))),window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,i);else{var s=document.createElement("a");document.body.appendChild(s),s.style.display="none",s.href=window.URL.createObjectURL(r),s.download=i,s.click(),window.URL.revokeObjectURL(s.href),document.body.removeChild(s)}}))},t.prototype.uploadQueryFile=function(t){var e=(t=t||{}).query||this.context.getQuery(),r=this.context.resolveEndpoint("UploadQueryFile",{modelId:e.getModel().getId()});return this.context.getServices().getHttpClient().post(r,t.data,{dataType:"form-data"}).then((function(t){return t.query}))},t}(),U=function(){function t(t){this.context=t,this.levels={}}return t.prototype.getAggregateData=function(t,e){var r=this;return new Promise((function(o,n){var i=function(t){var i=r.groupKeyToStr(e),s=t.get(i);s?o(s):n("Can't find data for ".concat(i))},s=r.getLevelDesc(t,!1);s&&s.data?i(s.data):s.receivedCallbacks.push(i)}))},t.prototype.setAggregateData=function(t,e){var r=this.getLevelDesc(t,!0);if(r.data=e,r.receivedCallbacks)for(var o=0,n=r.receivedCallbacks;o<n.length;o++){(0,n[o])(r.data)}r.receivedCallbacks=[]},t.prototype.updateAggregateData=function(t,e,r){var o=this.getLevelDesc(t,!0),n=this.groupKeyToStr(e);o.data.set(n,r)},t.prototype.groupKeyToStr=function(t){return JSON.stringify(t)},t.prototype.getLevelDesc=function(t,e){var r=this.levels[t];return!r&&e&&(r={receivedCallbacks:[],data:new Map},this.levels[t]=r),r},t.prototype.clear=function(){this.levels=[]},t}(),V=function(){function t(t){this.context=t,this.aggrs=null}return t.prototype.getAggrContainer=function(){return this.aggrs},t.prototype.calculate=function(t){console.warn("Grand totals and sub totals aggregation calculation can be used in Enterprise version only"),(t=t||{}).maxLevel=t.maxLevel>=0?t.maxLevel:0,this.aggrs=new U(this.context);var e=this.context.createQuery();e.loadFromData(this.context.getQuery().toJSONData());for(var r=this.context.getQuery().getAggregationSettings(),o=r.getAggregates().map((function(t){return t.colId})),n=e.getColumns().filter((function(t){return o.indexOf(t.id)<0})),i=0;i<n.length;i++)n[i].enabled=!1;r.hasGrandTotals()&&(this.aggrs.setAggregateData(0,new Map),t.resultObtained&&t.resultObtained({},0));for(var s=r.getGroups(),a=1;a<=s.length&&a<=t.maxLevel;a++)this.aggrs.setAggregateData(a,new Map),t.resultObtained&&t.resultObtained({},a);return Promise.resolve()},t.prototype.needRecalculation=function(){return!0},t.prototype.reset=function(){},t}(),W=function(){function t(t){this.context=t,this.modelLoader=null,this.queryStorage=null,this.querySynchronizer=null,this.dataFetcher=null,this.valueListResolver=null,this.queryFileLoader=null,this.aggrCalculator=null,this.httpClient=new o.eN,this.httpClient.defaultHeaders["x-eqjs-version"]="7.2.0",this.modelResolver=function(t){return new I},this.modelStorageResolver=null,this.queryResolver=function(t){return new P(t.getModel(),null,{context:t})},this.modelLoaderResolver=function(t){return new N(t)},this.queryStorageResolver=function(t){return new k(t)},this.querySynchronizerResolver=function(t){return new B(t)},this.vlrResolver=function(t){return new j(t)},this.dataFetcherResolver=function(t){return new Q(t)},this.queryFileLoaderResolver=function(t){return new G(t)},this.aggrCalculatoResolver=function(t){return new V(t)}}return t.prototype.reset=function(){this.modelStorage=null,this.modelLoader=null,this.queryStorage=null,this.querySynchronizer=null},t.prototype.getHttpClient=function(){return this.httpClient},t.prototype.createDataModel=function(){if(!this.modelResolver)throw"Model resolver is not defined";return this.modelResolver(this.context)},t.prototype.createQuery=function(){if(!this.queryResolver)throw"Query resolver is not defined";return this.queryResolver(this.context)},t.prototype.getModelLoader=function(){if(!this.modelLoader){if(!this.modelLoaderResolver)throw"ModelLoaderResolver is not defined";this.modelLoader=this.modelLoaderResolver(this.context)}return this.modelLoader},t.prototype.getModelStorage=function(){if(!this.modelStorage){if(!this.modelStorageResolver)throw"ModelStorageResolver is not defined";this.modelStorage=this.modelStorageResolver(this.context)}return this.modelStorage},t.prototype.getQueryStorage=function(){if(!this.queryStorage){if(!this.queryStorageResolver)throw"QueryStorageResolver is not defined";this.queryStorage=this.queryStorageResolver(this.context)}return this.queryStorage},t.prototype.getQuerySynchronizer=function(){if(!this.querySynchronizer){if(!this.querySynchronizerResolver)throw"QuerySynchronizerResolver is not defined";this.querySynchronizer=this.querySynchronizerResolver(this.context)}return this.querySynchronizer},t.prototype.getDataFetcher=function(){if(!this.dataFetcher){if(!this.dataFetcherResolver)throw"DataFetcherResolver is not defined";this.dataFetcher=this.dataFetcherResolver(this.context)}return this.dataFetcher},t.prototype.getValueListResolver=function(){if(!this.valueListResolver){if(!this.vlrResolver)throw"Resolver for ValueListResolver is not defined";this.valueListResolver=this.vlrResolver(this.context)}return this.valueListResolver},t.prototype.getQueryFileLoader=function(){if(!this.queryFileLoader){if(!this.queryFileLoaderResolver)throw"Resolver for QueryFileLoader is not defined";this.queryFileLoader=this.queryFileLoaderResolver(this.context)}return this.queryFileLoader},t.prototype.getAggregatesCalculator=function(){if(!this.aggrCalculator){if(!this.aggrCalculatoResolver)throw"Resolver for AggregatesCalculator is not defined";this.aggrCalculator=this.aggrCalculatoResolver(this.context)}return this.aggrCalculator},t.prototype.registerDataModelResolver=function(t){this.modelResolver=t},t.prototype.registerQueryResolver=function(t){this.queryResolver=t},t.prototype.registerModelLoaderResolver=function(t){this.modelLoaderResolver=t},t.prototype.registerModelStorageResolver=function(t){this.modelStorageResolver=t},t.prototype.registerQueryStorageResolver=function(t){this.queryStorageResolver=t},t.prototype.registerDataFetcherResolver=function(t){this.dataFetcherResolver=t},t.prototype.registerQuerySyncronizerResolver=function(t){this.querySynchronizerResolver=t},t.prototype.registerValueListResolver=function(t){this.vlrResolver=t},t.prototype.registerQueryFileLoaderResolver=function(t){this.queryFileLoaderResolver=t},t.prototype.registerAggregatesCalculator=function(t){this.aggrCalculatoResolver=t},t}(),H=function(){function t(t){this.context=t}return t.prototype.loadChunk=function(t){var e=this;return this.dataLoadPromise=new Promise((function(r,n){var i={chunk:t,success:function(n){for(var i=new o.XH({loader:e.context.dataLoader,chunkSize:e.context.resultTable.chunkSize}),s=n.resultSet,a=0,u=s.cols;a<u.length;a++){var l=u[a];i.columns.add(l)}i.setTotal(n.meta.totalRecords);for(var c=0,d=s.rows;c<d.length;c++){var h=d[c];i.addRow(h)}var p=0;n.meta&&n.meta.totalRecords&&(p=n.meta.totalRecords),r({table:i,total:p,hasNext:!t.needTotal||t.offset+t.limit<p})},error:function(t){return n(t)}};e.context.debugMode&&(i.debug="Data Chunk. Offset: ".concat(t.offset)),e.context.fetchDataChunk(i)})),this.dataLoadPromise},t}(),J=__webpack_require__(412);!function(t){t[t.None=0]="None",t[t.Model=1]="Model",t[t.Query=2]="Query",t[t.Result=4]="Result",t[t.Statement=8]="Statement",t[t.QueryStatus=16]="QueryStatus",t[t.All=65535]="All"}(_||(_={})),function(t){t.LoadModel="LoadModel",t.LoadQuery="LoadQuery",t.LoadQueryList="LoadQueryList",t.NewQuery="NewQuery",t.SaveQuery="SaveQuery",t.RemoveQuery="RemoveQuery",t.SyncQuery="SyncQuery",t.FetchData="FetchData",t.GetValueList="GetValueList",t.ExportResult="ExportResult",t.GetQueryFile="GetQueryFile",t.UploadQueryFile="UploadQueryFile"}(O||(O={}));var z,K=function(){function t(t){this.models=[],t&&o.P6.assign(this.models,[],t)}return t.prototype.getModels=function(){var t=this;return new Promise((function(e,r){e(t.models)}))},t}();!function(t){t[t.Error=0]="Error",t[t.Success=1]="Success"}(z||(z={}));var Y=function(){function t(t){this.context=t}return t.prototype.setFormat=function(t,e){this.format=t,this.responseType=e},t.prototype.export=function(t){t=t||{};var e=this.context.getServices().getHttpClient(),r=this.format||"csv",o=t.query||this.context.getQuery(),n=o.getModel().getId(),i={settings:t.settings,chunk:a};void 0!==t.queryId?i.queryId=t.queryId:i.query=o.toJSONData(),t.data&&(i.data=t.data),t.options&&(i.options=t.options);var s=this.context.resolveEndpoint("ExportResult",{modelId:n,format:r}),u=e.post(s,i,{responseType:this.responseType}),l=u.getRequest();return u.then((function(t){var e=new Blob([t]),o=l.getXMLHttpRequest().getResponseHeader("Content-Disposition"),n=o?o.match(/filename="(.*)"/)[1]:"export-data."+r;if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(e,n);else{var i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=window.URL.createObjectURL(e),i.download=n,i.click(),window.URL.revokeObjectURL(i.href),document.body.removeChild(i)}}))},t}(),$=function(){return $=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},$.apply(this,arguments)},X=function(){function t(){var t=this;this.options={syncSortOrderWithColumnsOrder:!0},this.servicesInitialized=!1,this.internalListCache={},this.loadModelOnStart=!0,this.loadQueryOnStart=!1,this.useStoredQueryOnFetch=!1,this.debugMode=!1,this._backendInfo={type:"EQN-ANC",subType:"asp-net-core-razor"},this.endpointVarsRegex=/\{.*?\}/g,this.elasticPaging=!1,this._predefinedListRequestHandlers={_DSDE:function(e,r){return r(t.getModel().getAllDateMacros().map((function(t){return{id:"${{"+t+"}}",text:o.ag.getText(t)}}))),!0},_DSTE:function(e,r){return r(t.getModel().getAllTimeMacros().map((function(t){return{id:"${{"+t+"}}",text:o.ag.getText(t)}}))),!0}},this._listRequestHandler=function(e,r){if(null!=e&&e.listName){var n=t.getQuery(),i=o.P6.assign({listName:e.listName},e.editorParams),s={},a=/@{{(.+?)}}/;for(var u in i)if(i[u]){var l=i[u].match(a);if(l){var c=n.getOneValueForAttr(l[1]);c||(c=""),s[u]=i[u].replace(a,c)}}var d={listName:s.listName,editorId:e.editorId,queryParams:s},h=t.getListFromCache(e);if(h&&h.length>0)r(h);else{var p=!1,f=t._predefinedListRequestHandlers[e.editorId];f&&(p=f(e,r)),!p&&t.clientListRequestHandler&&(p=t.clientListRequestHandler(e,r)),p||t.loadValueList({params:d,success:function(o){o&&t.addListToCache(e,o),r(o)},error:function(t){r(null)}})}}},this.baseEndpoint="api/easyquery",this.eqServices=new W(this),this.widgets=new Array,this.eventEmitter=new o.vp(this),this.exporters=new Map,this.endpoints=new Map,this.dataLoader=new H(this),this.resultTable=new o.XH({loader:this.dataLoader,onUpdate:this.onResultTableUpdate.bind(this)}),this.resultTable.id="ResultTable",this.errorHandlerId=this.addEventListener("error",(function(t,e){e.result=z.Error;var r=e.action?e.action+" error":"Error",o=e.text?e.text:"";e.sourceError&&e.sourceError.message!==o&&(o+="\n"+e.sourceError),console.error(r+": "+o)}))}return t.prototype.getServices=function(){return this.eqServices},t.prototype.registerExporter=function(t,e){this.exporters.set(t,e)},t.prototype.registerServerExporter=function(t,e){this.registerExporter(t,(function(r){var o=new Y(r);return o.setFormat(t,e),o}))},t.prototype.getExporter=function(t){var e=this.exporters.get(t);return e?e(this):null},t.prototype.getExportFormats=function(){return Array.from(this.exporters.keys())},t.prototype.addDefaultExporters=function(){this.registerServerExporter("csv","arraybuffer"),this.registerServerExporter("excel-html","arraybuffer")},t.prototype.resolveEndpoint=function(t,e){e=e||{};var r=this.endpoints.get(t);if(!r)throw t+" endpoint is not defined";var o=r.match(this.endpointVarsRegex);if(o)for(var n=0,i=o;n<i.length;n++){var s=i[n],a=s.substring(1,s.length-1),u=e[a];if(!u)if("modelId"==a)u=this.getModel().getId();else{if("queryId"!=a)throw"Parameter [".concat(a,"] is not defined");u=this.getQuery().getId()}r=r.replace(s,u)}return r},t.prototype.setEndpoint=function(t,e){this.endpoints.set(t,e)},t.prototype.setEnpointIfNotExist=function(t,e){this.endpoints.has(t)||this.endpoints.set(t,e)},t.prototype.setDefaultEndpoints=function(t){this.setEnpointIfNotExist("GetModel",e.combinePath(t,"models/{modelId}")),this.setEnpointIfNotExist("GetQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SaveQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SyncQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}/sync")),this.setEnpointIfNotExist("NewQuery",e.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("RemoveQuery",e.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("GetQueryList",e.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("FetchData",e.combinePath(t,"models/{modelId}/fetch")),this.setEnpointIfNotExist("GetValueList",e.combinePath(t,"models/{modelId}/valuelists/{listId}")),this.setEnpointIfNotExist("ExportResult",e.combinePath(t,"models/{modelId}/export/{format}")),this.setEnpointIfNotExist("GetQueryFile",e.combinePath(t,"models/{modelId}/getqueryfile/{format}")),this.setEnpointIfNotExist("UploadQueryFile",e.combinePath(t,"models/{modelId}/uploadqueryfile"))},t.prototype.initStart=function(){this.servicesInitialized=!0},t.prototype.init=function(t){var e=this;(this.servicesInitialized||this.initStart(),t=t||{},this.setOptions(t),void 0!==t.debugMode&&(this.debugMode=t.debugMode),void 0!==t.chunkSize&&(this.resultTable.chunkSize=t.chunkSize),void 0!==t.elasticPaging&&(this.elasticPaging=t.elasticPaging),t.listCache&&this.setExternalListCache(t.listCache),t.locale&&o.ag.setCurrentLocale(t.locale),t.localeSettings&&o.ag.updateLocaleSettings(t.localeSettings),t.endpoint&&(this.baseEndpoint=t.endpoint,console.warn("The `endpoint` option is deprecated.\nPlease use `context.useEndpoint(endpointURL)` function instead.")),this.setDefaultEndpoints(this.baseEndpoint),t.modelStorageResolver)&&this.getServices().registerModelStorageResolver(t.modelStorageResolver);if(this.loadQueryOnStart=!1,t.loadQueryOnStart&&(this.loadQueryOnStart=t.loadQueryOnStart),this.loadModelOnStart=!0,void 0!==t.loadModelOnStart&&(this.loadModelOnStart=t.loadModelOnStart),t.handlers&&(t.handlers.onInit&&this.addEventListener("ready",t.handlers.onInit),t.handlers.afterLoadModel&&this.addEventListener("loadModel",t.handlers.afterLoadModel),t.handlers.afterLoadQuery&&this.addEventListener("loadQuery",t.handlers.afterLoadQuery),t.handlers.afterSyncQuery&&this.addEventListener("syncQuery",t.handlers.afterSyncQuery),t.handlers.afterFetchData&&this.addEventListener("fetchData",t.handlers.afterFetchData),t.handlers.afterExportResult&&this.addEventListener("exportResult",t.handlers.afterExportResult),t.handlers.onProcessStart&&this.addEventListener("processStart",t.handlers.onProcessStart),t.handlers.onProcessEnd&&this.addEventListener("processEnd",t.handlers.onProcessEnd),t.handlers.onError&&(this.removeEventListener("error",this.errorHandlerId),this.addEventListener("error",t.handlers.onError)),t.handlers.onListRequest&&(this.clientListRequestHandler=t.handlers.onListRequest),t.handlers.beforeLoadModel&&(this.beforeLoadModel=t.handlers.beforeLoadModel),t.handlers.beforeLoadQuery&&(this.beforeLoadQuery=t.handlers.beforeLoadQuery),t.handlers.beforeSyncQuery&&(this.beforeSyncQuery=t.handlers.beforeSyncQuery),t.handlers.beforeFetchData&&(this.beforeFetchData=t.handlers.beforeFetchData),t.handlers.beforeExportResult&&(this.beforeExportResult=t.handlers.beforeExportResult)),this.initialQuery=t.initialQuery,this.defaultQueryId=t.defaultQueryId||"",this.defaultModelId=t.defaultModelId||"__default",this.eqServices.getModelLoader().init(t),this.eqServices.getQueryStorage().init(t),!1!==t.useDefaultExporters&&this.addDefaultExporters(),t.serverExporters){this.exporters.clear();for(var r=0,n=t.serverExporters;r<n.length;r++){var i=n[r];this.registerServerExporter(i,"arraybuffer")}}var s=this.getQuery();t.defaultQueryId&&s.setId(t.defaultQueryId),this.widgets.forEach((function(r){var o={};t.widgets&&t.widgets[r.getWidgetType()]&&(o=t.widgets[r.getWidgetType()]),r.init(e,o)})),this.loadModelOnStart?this.loadDefaultModel():this.fireEvent("ready")},t.prototype.setOptions=function(t){o.P6.assignDeep(this.options,t)},Object.defineProperty(t.prototype,"backendInfo",{get:function(){return this._backendInfo},enumerable:!1,configurable:!0}),t.prototype.useEndpoint=function(t){return this.baseEndpoint=t,this},t.prototype.useBackend=function(t){if(t.type&&(this._backendInfo.type=t.type),t.subType)this._backendInfo.subType=t.subType;else switch(this._backendInfo.type){case"EQN-ANC":this._backendInfo.subType="asp-net-core-razor";break;case"EQN-ASP":this._backendInfo.subType="asp-net-4-mvc";break;default:this._backendInfo.subType="other"}return this},t.prototype.addWidget=function(t){this.widgets.push(t)},t.prototype.getAllWidgetsByType=function(t){return this.widgets.filter((function(e){return e.getWidgetType()===t}))},t.prototype.getWidgetByType=function(t){var e=this.getAllWidgetsByType(t);return e.length>0?e[0]:null},t.prototype.refreshWidgets=function(t){void 0===t&&(t=_.All),this.widgets.forEach((function(e){e.belongsToGroup(t)&&e.refresh()}))},t.prototype.addQueryChangedCallback=function(t){this.getQuery().addChangedCallback(t)},t.prototype.removeQueryChangedCallback=function(t){this.getQuery().removeChangedCallback(t)},t.prototype.createQuery=function(){return this.eqServices.createQuery()},t.prototype.getQuery=function(){if(!this.query){if(!this.servicesInitialized)throw new Error("Can't create query until the context is initialized");this.query=this.createQuery()}return this.query},t.prototype.getModel=function(){return this.dataModel||(this.dataModel=this.eqServices.createDataModel()),this.dataModel},t.prototype.loadModelFromData=function(t){this.getQuery().loadModelData(t),this.dataModel=this.getQuery().getModel()},t.prototype.setDefaultModelId=function(t){this.defaultModelId=t},t.prototype.startProcess=function(t,e){this.eventEmitter.fire("processStart",t),this.widgets.forEach((function(t){t.belongsToGroup(e)&&t.onProcessStart()}))},t.prototype.endProcess=function(t,e){this.eventEmitter.fire("processEnd",t),t.result===z.Error&&this.throwError(t),this.widgets.forEach((function(t){t.belongsToGroup(e)&&t.onProcessEnd()}))},t.prototype.throwError=function(t){t.result=z.Error,this.eventEmitter.fire("error",t)},t.prototype.loadDefaultModel=function(){var t=this;this.loadModel({modelId:this.defaultModelId,silent:!0,success:function(){t.refreshWidgets(_.Model);var e=t.getQuery();t.fireEvent("initialModelLoad"),t.initialQuery&&e.loadFromData(t.initialQuery,{changeStatus:!1}),t.loadQueryOnStart?t.loadQuery({queryId:t.defaultQueryId,modelId:t.defaultModelId,success:function(){t.refreshWidgets(_.Query),t.fireEvent("ready")}}):(t.refreshWidgets(_.Query),t.fireEvent("ready"))}})},t.prototype.clearQuery=function(){var t=this.getQuery();t.clear(),t.fireChangedEvent({part:x.All})},t.prototype.clearResult=function(){this.resultTable.clear(),this.resultStatement=null,this.resultContent=null},t.prototype.setExternalListCache=function(t){this.externalListCache=t},t.prototype.getListFromCache=function(t){var e=this.getListCacheKey(t);return this.externalListCache?this.externalListCache.get(e):this.internalListCache[e]},t.prototype.getListCacheKey=function(t){var e="SQL"==t.listName?"SQL_"+t.editorId:t.listName;return t.queryParams&&(e+="_"+Object.keys(t.queryParams).filter((function(t){return"listName"!=t})).map((function(e){return t.queryParams[e]})).join("_")),e},t.prototype.addListToCache=function(t,e){var r=this.getListCacheKey(t);this.externalListCache?this.externalListCache.set(r,e):this.internalListCache[r]=e},t.prototype.resetListCache=function(){this.externalListCache?this.externalListCache.clear():this.internalListCache={}},t.prototype.getListRequestHandler=function(){return this._listRequestHandler},t.prototype.addLocale=function(t,e){o.ag.addLocale(t,e)},t.prototype.addEventListener=function(t,e){var r=this;return this.eventEmitter.subscribe(t,(function(t){return e(r,t.data)}))},t.prototype.removeEventListener=function(t,e){this.eventEmitter.unsubscribe(t,e)},t.prototype.fireEvent=function(t,e){this.eventEmitter.fire(t,e)},t.prototype.getBaseEndpoint=function(){return this.baseEndpoint},t.prototype.loadValueList=function(t){var e=this;t=t||{},this.startProcess({action:O.GetValueList,text:"Loading values"},_.Result),this.eqServices.getValueListResolver().loadValueList(t).then((function(r){e.endProcess({result:z.Success,action:O.GetValueList,text:"Values loaded"},_.Result),t.success&&t.success(r)})).catch((function(r){var o=t&&t.params?t.params.editorId:"undefined",n="Can't load the value list for editor ".concat(o,".\n ").concat(r.message);e.endProcess({result:z.Error,action:O.GetValueList,text:n,sourceError:r},_.Result),t.error&&t.error(n,"GetValueList")}))},t.prototype.loadModel=function(t){var e=this;this.beforeLoadModel&&this.beforeLoadModel(this,t);var r=t.modelId||"__default",o=t.silent||!1;return this.startProcess({action:O.LoadModel,text:"Loading model: "+r},_.Model),this.eqServices.getModelLoader().startModelLoading(t).then((function(n){return n?(e.loadModelFromData(n),e.dataModel.isEmpty()&&console.warn("Empty model has been loaded. Model ID: ".concat(e.dataModel.getId()))):console.warn("Model has not been changed."),e.fireEvent("loadModel"),e.endProcess({result:z.Success,action:O.LoadModel,text:"Model loaded: "+r},_.Model),o||(e.clearQuery(),e.clearResult(),e.refreshWidgets()),t.success&&t.success(e.getModel()),e.getModel()})).catch((function(o){var n="Can't load model ".concat(r,".\n ").concat(o.message);return e.endProcess({result:z.Error,action:O.LoadModel,text:n,sourceError:o},_.Model),t.error&&t.error(n,"LoadModel"),e.getModel()}))},t.prototype.callWhenModelLoaded=function(t){this.eqServices.getModelLoader().getModelPromise().then((function(){t()}))},t.prototype.loadQuery=function(t){var e=this;t=t||{};var r=this.eqServices.getModelLoader();this.clearResult(),r.getModelPromise().then((function(){var r=(t=t||{}).queryId,o=t.silent||!1;e.beforeLoadQuery&&e.beforeLoadQuery(e,t),e.startProcess({action:O.LoadQuery,text:"Query loading: "+r},_.Query),e.eqServices.getQueryStorage().loadQuery(t).then((function(n){n&&e.query.loadFromData(n,{validate:!1}),e.limitCustomSqlColumns(),e.fireEvent("loadQuery"),e.endProcess({result:z.Success,action:O.LoadQuery,text:"Query loaded: "+r},_.Query),e.query.resetModified(),o||(e.query.fireChangedEvent({part:x.Properties,wasModified:e.query.isModified()}),e.refreshWidgets()),t.success&&t.success(e.query)})).catch((function(r){var o=e.getQuery();r.message="Can't load query ["+o.getId()+"]\n"+(r.message||""),t.error&&t.error(r.message,O.LoadQuery),e.endProcess({result:z.Error,action:O.LoadQuery,text:r.message,sourceError:r},_.Query)}))})).catch((function(t){console.error(t)}))},t.prototype.loadQueryList=function(t){var e=this;this.eqServices.getModelLoader().getModelPromise().then((function(){e.startQueryListLoading(t)})).catch((function(t){var r="Can't load the list of available queries.\n ".concat(t.message);e.throwError({action:O.LoadQueryList,text:r,sourceError:t})}))},t.prototype.startQueryListLoading=function(t){var e=this;t=t||{},this.eqServices.getQueryStorage().getQueryList(t).then((function(e){t.success&&t.success(e)})).catch((function(r){var o="Can't load the list of available queries.\n ".concat(r.message);t.error?t.error(o,"LoadQueryList"):e.throwError({action:O.LoadQueryList,text:o,sourceError:r})}))},t.prototype.newQuery=function(t){var e=this,r=void 0===(t=t||{}).clearQuery||t.clearQuery;this.query.reset(r),t.queryId&&this.query.setId(t.queryId),t.name&&this.query.setName(t.name),t.description&&this.query.setDescription(t.description);var o=t.silent||!1,n=!0;void 0!==t.useStorage&&(n=t.useStorage);var i=function(){var t=e.getQuery();t.isNewbie=!0,o||t.fireChangedEvent({part:x.All,wasModified:t.isModified()})};n?(this.startProcess({action:O.NewQuery,text:"New query creation..."},_.Query),this.eqServices.getQueryStorage().newQuery(t).then((function(r){r&&e.query.loadFromData(r),e.endProcess({result:z.Success,action:O.NewQuery,text:"A new query has been created"},_.Query),i(),t.success&&t.success()})).catch((function(r){var o="Can't create a new query.\n".concat(r.message);e.endProcess({result:z.Error,action:O.NewQuery,text:o,sourceError:r},_.Query),t.error&&t.error(o,"NewQuery")}))):i();return this.query},t.prototype.saveQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:O.SaveQuery,text:"Query saving: "+r.getId()},_.Query),this.eqServices.getQueryStorage().saveQuery(t).then((function(o){e.endProcess({action:O.SaveQuery,result:z.Success,text:"Query saved: "+r.getId()},_.Query),o&&r.loadFromData(o),r.resetModified(),r.isNewbie=!1,t.success&&t.success()})).catch((function(o){var n="Can't save query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({action:O.SaveQuery,result:z.Error,text:n,sourceError:o},_.Query),t.error&&t.error(n,O.SaveQuery)}))},t.prototype.removeQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:O.RemoveQuery,text:"Query deleting: "+r.getId()},_.Query),this.eqServices.getQueryStorage().removeQuery(t).then((function(){r.reset(),e.endProcess({action:O.RemoveQuery,result:z.Success,text:"Query deleted: "+r.getId()},_.Query),t.success&&t.success()})).catch((function(o){var n="Can't remove query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({action:O.RemoveQuery,result:z.Error,text:n,sourceError:o},_.Query),t.error&&t.error(n,"RemoveQuery")}))},t.prototype.syncQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.beforeSyncQuery&&this.beforeSyncQuery(this,t),this.startProcess({action:O.SyncQuery,text:"Query syncing: "+r.getId()},_.Query),this.eqServices.getQuerySynchronizer().syncQuery(t).then((function(o){if(e.resultStatement=o&&o.statement?o.statement:"",e.fireEvent("syncQuery"),e.refreshWidgets(_.Statement),e.endProcess({result:z.Success,action:O.SyncQuery,text:"Query synced: "+r.getId()},_.Query),o){if(o.querySaved){var n=o.query;n&&(r.setId(n.id),r.setName(n.name),r.setDescription(n.desc),r.extraData=n.extraData),r.resetModified(),e.refreshWidgets(_.QueryStatus)}t.success&&t.success(o)}})).catch((function(o){var n="Can't synchronize query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({result:z.Error,action:O.SyncQuery,text:n,sourceError:o},_.Query),t.error&&t.error(n,"SyncQuery")}))},t.prototype.fetchData=function(t){var e=this,r=void 0!==(t=t||{}).elasticPaging?t.elasticPaging:this.elasticPaging;this.resultTable.elasticChunks=r,t.chunk=t.chunk||{offset:0,limit:this.resultTable.chunkSize,needTotal:!r},this.debugMode&&(t.debug="Fetching the result set. Initial chunk"),this.query.tryValidate({checkExpressions:!0})&&(t.groupFetchSuccess&&(this.afterGroupFetch=t.groupFetchSuccess),this.resultTable.elasticChunks&&t.chunk.limit++,this.fetchDataChunk($($({},t),{success:function(r){if(r.statement&&(e.resultStatement=r.statement,e.refreshWidgets(_.Statement)),e.getServices().getAggregatesCalculator().reset(),e.resultContent=r,r.resultSet){e.resultTable.clear(),e.resultTable.id=e.query.getId();for(var o=r.resultSet,n=0,i=o.cols;n<i.length;n++){var s=i[n];e.resultTable.columns.add(s)}r.meta&&void 0!==r.meta.totalRecords&&e.resultTable.setTotal(r.meta.totalRecords);var a=o.rows.length;e.resultTable.elasticChunks&&a===t.chunk.limit&&o.rows.splice(o.rows.length-1,1);for(var u=0,l=o.rows;u<l.length;u++){var c=l[u];e.resultTable.addRow(c)}e.resultTable.elasticChunks&&(e.resultTable.total=a<t.chunk.limit?o.rows.length:0),e.resultTable.fireUpdated()}t.success&&t.success(r)}})))},t.prototype.getQueryFile=function(t){var e=this,r=this.getQuery();this.startProcess({action:O.GetQueryFile,text:"Getting query file: "+r.getId()},_.Query),this.getServices().getQueryFileLoader().getQueryFile(t).then((function(){e.endProcess({result:z.Success,action:O.GetQueryFile,text:"Getting query file: "+r.getId()},_.Query),t.success&&t.success()})).catch((function(o){var n="Can't get file for query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({result:z.Error,action:O.GetQueryFile,text:n,sourceError:o},_.Query),t.error&&t.error(n,"GetQueryFile")}))},t.prototype.uploadQueryFile=function(t){var e=this,r=this.getQuery();this.startProcess({action:O.UploadQueryFile,text:"Uploading query file: "+r.getId()},_.Query),this.getServices().getQueryFileLoader().uploadQueryFile(t).then((function(o){r.loadFromData(o),e.fireEvent("loadQuery"),e.refreshWidgets(),e.endProcess({result:z.Success,action:O.UploadQueryFile,text:"Uploading query file: "+r.getId()},_.Query),t.success&&t.success()})).catch((function(o){var n="Can't upload a file for query ".concat(r.getId(),".\n ").concat(o.message);e.endProcess({result:z.Error,action:O.UploadQueryFile,text:n,sourceError:o},_.Query),t.error&&t.error(n,"UploadQueryFile")}))},t.prototype.fetchDataChunk=function(t){var e=this,r=this.getQuery().getId(),o=t||{};this.useStoredQueryOnFetch&&(o.queryId=this.query.getId()),this.beforeFetchData&&this.beforeFetchData(this,o),this.startProcess({action:O.FetchData,text:"Fetching data for the query: "+r},_.Result),this.eqServices.getDataFetcher().fetchData(o).then((function(t){t.statement&&(e.resultStatement=t.statement),e.resultContent=t,o.success&&o.success(t),e.fireEvent("fetchData"),e.endProcess({result:z.Success,action:O.FetchData,text:"Data fetching is finished for the query: "+r},_.Result)})).catch((function(t){var n="Data fetching error for the query ".concat(r,". \n").concat(t.message);e.endProcess({result:z.Error,action:O.FetchData,text:n,sourceError:t},_.Result),o.error&&o.error(n,O.FetchData)}))},t.prototype.onResultTableUpdate=function(){var t=this,e=this.query.getAggregationSettings(),r=this.getServices().getAggregatesCalculator();e.needAggrCalculation()&&r.needRecalculation()&&r.calculate({maxLevel:e.getGroups().length+1,resultObtained:function(e,r){t.afterGroupFetch&&t.afterGroupFetch(e)},errorOccurred:function(e){var r="Data fetching error on group level ".concat(e.level," query. \n").concat(e.message);t.throwError({action:O.FetchData,text:r,sourceError:e})}})},t.prototype.fetchDrillDownData=function(t){var e=this;(t=t||{}).chunk=t.chunk||{offset:0,limit:this.resultTable.chunkSize,needTotal:!0};var r=t.query.getId();this.startProcess({action:O.FetchData,text:"DrillDown executing: "+r},_.Result),this.eqServices.getDataFetcher().fetchData(t).then((function(o){e.endProcess({result:z.Success,action:O.FetchData,text:"DrillDown execution error: "+r},_.Result),t.success&&t.success(o)})).catch((function(o){var n="Drill-down data fetching error for query ".concat(r,". \n").concat(o.message);e.endProcess({result:z.Error,action:O.FetchData,text:n},_.Result),t.error?t.error(n,"DrillDown"):e.throwError({action:O.FetchData,text:n})}))},t.prototype.exportResult=function(t){var e=this;(t=t||{}).chunk=t.chunk||a,this.beforeExportResult&&this.beforeExportResult(this,t);var r=t.format;if(r){var n=this.getExporter(r);if(n){var i=this.getQuery().getId();this.useStoredQueryOnFetch&&(t.queryId=i),this.startProcess({action:O.ExportResult,text:"Exporting result for query: "+i},_.Result);var s=o.ag.getLocaleSettings();t.settings=s;var u=this.query.getAggregationSettings();u.hasAggregates()&&(u.hasGrandTotals()||u.hasGroups())&&(t.aggregates=u.saveToData()),n.export(t).then((function(r){e.fireEvent("exportResult"),e.endProcess({result:z.Success,action:O.ExportResult,text:"The result set for query [".concat(i,"] has been successfully exported")},_.Result),t.success&&t.success()})).catch((function(r){var o="Error on exporting data for query ".concat(i,". \n").concat(r.message);e.endProcess({result:z.Error,action:O.ExportResult,text:o,sourceError:r},_.Result),t.error&&t.error(o,"ExportResult")}))}}},t.prototype.limitCustomSqlColumns=function(){this.options.allowCustomExpressions||this.query.getColumns().forEach((function(t){t.expr.tag===d.CustomSql&&(t.enabled=!1)}))},t}(),Z=function(){function t(t){this.slot=t,this._id=o.P6.generateId(this.getWidgetType())}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),t.prototype.init=function(t,e){this.context=t},t.prototype.getContext=function(){return this.context},t.prototype.refresh=function(){this.refreshCore()},t.prototype.refreshCore=function(){},t.prototype.onProcessStart=function(){this.onProcessStartCore()},t.prototype.onProcessStartCore=function(){},t.prototype.onProcessEnd=function(){this.onProcessEndCore()},t.prototype.onProcessEndCore=function(){},t.prototype.belongsToGroup=function(t){return void 0===t||null==t||0!=(t&this.group)},t.prototype.destroy=function(){this.destroyCore()},t.prototype.destroyCore=function(){},t}(),tt=new(function(){function t(t,e,r){this.major=t,this.minor=e,this.update=r}return t.prototype.toString=function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.update)},t}())(6,2,0);o.ag.updateDefaultTexts({NewQueryName:"[New query]",Today:"Today",Yesterday:"Yesterday",Tomorrow:"Tomorrow",FirstDayOfMonth:"First day of the month",LastDayOfMonth:"Last day of the month",FirstDayOfWeek:"First day of the week",FirstDayOfYear:"First day of the year",FirstDayOfNextWeek:"First day of the next week",FirstDayOfNextMonth:"First day of the next month",FirstDayOfNextYear:"First day of the next year",Now:"Now",HourStart:"This hour start",Midnight:"Midnight",Noon:"Noon",Entities:{},Attributes:{},Operators:{},AggregateFunctions:{}})})(),__webpack_exports__})()));
|
|
2
2
|
//# sourceMappingURL=easyquery.core.min.js.map
|