@easyquery/core 7.2.0 → 7.2.1-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 +108 -54
- 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/dm/data_model.d.ts +6 -1
- package/dist/lib/dm/data_model.js +8 -0
- package/dist/lib/dm/data_model.js.map +1 -1
- package/dist/lib/dm/value_editor.js.map +1 -1
- package/dist/lib/main/context.d.ts +13 -0
- package/dist/lib/main/context.js +57 -18
- package/dist/lib/main/context.js.map +1 -1
- package/package.json +2 -2
|
@@ -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()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){"use strict";var n,o;r.d(e,"b",(function(){return n})),r.d(e,"d",(function(){return s})),r.d(e,"f",(function(){return m})),r.d(e,"g",(function(){return E})),r.d(e,"h",(function(){return v})),r.d(e,"i",(function(){return b})),r.d(e,"j",(function(){return x})),r.d(e,"a",(function(){return D})),r.d(e,"c",(function(){return A})),r.d(e,"e",(function(){return F})),r.d(e,"k",(function(){return a})),r.d(e,"l",(function(){return 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"}(n||(n={})),function(t){t[t.Data=0]="Data",t[t.Virtual=1]="Virtual",t[t.Lookup=2]="Lookup"}(o||(o={}));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 n=r[e].split(": "),o=n.shift(),i=n.join(": ");t[o]=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 d(t,e){for(var r="",n=0;n<e;n++)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"},o={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":o},s=[];function a(t){for(var e=0,r=s;e<r.length;e++){(0,r[e])(t)}}function l(){return e.localeId}function d(t){var r=i[t];r?u.assignDeep(e,r):(e.englishName=t,e.displayName=t,e.texts=u.assignDeep({},o.texts)),e.localeId=t}function c(){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 n=e;t&&(r.localeId||(r.localeId=t),(n=i[t])||(n=u.assignDeep({},o),i[t]=n)),u.assignDeep(n,r)}function f(){var t,r,n,o,i,s,a="object"==typeof navigator?navigator.language:void 0;t=a,r=new Date(2020,5,7,19,34,56,88),n=r.toLocaleDateString(t,{year:"numeric",month:"numeric",day:"numeric"}),o=r.toLocaleTimeString(t,{hour:"numeric",minute:"numeric",second:"numeric"}),i=n.replace("07","dd").replace("7","d").replace("06","MM").replace("6","M").replace("2020","yyyy").replace("20","yy"),s=o.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 y(t){var e,r=c();switch(t){case n.Date:e=r.shortDateFormat;break;case n.Time:e=r.shortTimeFormat;break;default:e=r.shortDateFormat+" "+r.shortTimeFormat}return e}function g(t){var e,r=c();switch(t){case n.Date:e=r.longDateFormat;break;case n.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"),d(t)},t.setCurrentLocale=d,t.getText=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=e.texts,o="";if(t&&t.length)for(var i=t.length,s=0;s<i&&"object"==typeof(o=n[t[s]]);s++)n=o;return o},t.getLocaleSettings=c,t.getOneLocaleSetting=function(t){return e.settings[t]},t.getShortMonthName=function(t){var e=c();if(t>0&&t<13)return e.shortMonthNames[t-1];throw"Wrong month number: "+t},t.getLongMonthName=function(t){var e=c();if(t>0&&t<13)return e.longMonthNames[t-1];throw"Wrong month number: "+t},t.getShortWeekDayName=function(t){var e=c();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=c();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 n=i[r];n.texts=u.assignDeep({},t,n.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({},o),f())},t.dateTimeToStr=function(t,e,r){return r?"d"==r?r=y(n.Date):"D"==r?r=g(n.Date):"f"==r?r=y(n.DateTime):"F"==r&&(r=g(n.DateTime)):r=y(e),u.dateTimeToStr(t,r)},t.numberToStr=function(e,r){if(r&&r.length>0){var n=r.charAt(0).toUpperCase();if("S"===n)return function(e,r){if(!m[r]){var n=r.split("|").filter((function(t){return t.length>0})).map((function(t){return t.split("=")}));if(m[r]={},n.length>0)if(n[0].length>1)for(var o=0,i=n;o<i.length;o++){var s=i[o];m[r][Number.parseInt(s[1])]=s[0]}else n.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(n)>=0){var o=l();return e.toLocaleString(o,function(t){var e=c(),r=t[0].toUpperCase(),n=t.length>1?Number.parseInt(t.slice(1)):"D"==r?1:2;switch(r){case"D":return{style:"decimal",useGrouping:!1,minimumIntegerDigits:n};case"C":return{style:"currency",currency:e.currency,minimumFractionDigits:n};default:return{style:"decimal",minimumFractionDigits:n}}}(r))}return function(t,e){for(var r=t.toString(),n="",o=r.length-1,i=e.length-1;i>=0;i--){var s=e.charAt(i);"#"===s||"0"===s?o>=0?(n+=r.charAt(o),o--):"0"===s&&(n+=0):n+=s}return n.split("").reverse().join("")}(Math.trunc(e),r)}var i=c();return u.numberToStr(e,i.decimalSeparator)},t.booleanToStr=function(e,r){if(r&&r.length>0&&"S"===r.charAt(0).toUpperCase()){var n=r.slice(1).split("|");if(n.length>1){var o=n[e?1:0];return t.getText(o)||o}}return""+e};var m={}}(a||(a={})),function(t){t.getAllDataTypes=function(){return Object.values(n).filter((function(t){return"number"==typeof t}))},t.getDateDataTypes=function(){return[n.Time,n.Date,n.DateTime]},t.getStringDataTypes=function(){return[n.String,n.Memo,n.FixedChar]};var e=[n.Byte,n.Word,n.Int32,n.Int64,n.Float,n.Currency,n.Autoinc];t.getNumericDataTypes=function(){return e};var r=[n.Byte,n.Word,n.Int32,n.Int64,n.Autoinc];function o(t,e,r){e||(e={});for(var n=0,s=r;n<s.length;n++){var a=s[n];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]),o(t,e[u],[l])):e[u]=l}}return e}function i(t){for(var e=[],r=0,n=t;r<n.length;r++){var o=n[r];e.push(o)}return e}t.assign=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0;n<e.length;n++){var o=e[n];if(o)for(var i in o)o.hasOwnProperty(i)&&(t[i]=o[i])}return t},t.assignDeep=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return o(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,n=e.length,o=0;o<r&&o<n;o++)e[o]=t[o]},t.createArrayFrom=i,t.findItemById=function(t,e){for(var r=t.length,n=0;n<r;n++)if(t[n].id===e)return t[n];return null},t.findItemIndexById=function(t,e){for(var r=t.length,n=0;n<r;n++)if(t[n].id===e)return n;return-1},t.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=t.length,n=0;n<r;n++)if(e==t[n])return n;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 n=t.splice(e,1)[0];t.splice(r,0,n)},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,n){void 0===r&&(r=0);for(var o=t.length>>>0,i=r>>0,s=i<0?Math.max(o+i,0):Math.min(i,o),a=void 0===n?o:n>>0,u=a<0?Math.max(o+a,0):Math.min(a,o);s<u;)t[s]=e,s++;return t},t.shiftToFitWindow=function(t,e){var r=document.getElementsByTagName("body")[0],n=window.innerWidth||document.documentElement.clientWidth||r.clientWidth,o=t+e,i=0;return o>n&&t+(i=n-o-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==n.Unknown||e==n.Unknown||t==e||t==n.Date&&e==n.DateTime||t==n.DateTime&&e==n.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 n=r/e,o="";o+=t[0];for(var i=n,s=void 0,a=1;a<r;a++)s=t[a],a+1>i&&(o+=s,i+=n);return o}return t}function l(t,e,r){return t.substr(0,e)+r+t.substr(e+r.length)}function c(t,e){return Math.floor(Math.random()*(e-t))+t}function h(t){var e=parseInt(t);if(isNaN(e))throw'"'+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("-"),n=1,o=e;r.length<e&&(n=e/r.length,o=r.length);for(var i="",s=0;s<o;s++)i+=u(r[s],n);return i}(t,4):t;e&&e.length>0&&(e+="-");var r=d("",2),n=s.length-1;return r=l(r,0,s[c(0,n)]),e+(r=l(r,1,s[c(0,n)]))+function(t){var e=36,r=14,n=d("",r),o=t;do{n=l(n,r--,s[o%e]),o=Math.floor(o/=e)}while(o>0);return i=n.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,"-"),n=e.replace(/[^a-zA-Z0-9_]/g,"-").split("-"),o=r.split("-"),i=n.indexOf("MM"),s=n.indexOf("dd"),a=n.indexOf("yyyy"),u=n.indexOf("HH"),l=n.indexOf("mm"),d=n.indexOf("ss"),c=new Date;try{var p=a>-1&&a<o.length?h(o[a]):c.getFullYear(),f=i>-1&&i<o.length?h(o[i])-1:c.getMonth()-1;if(f>11)throw"";var y=s>-1&&s<o.length?h(o[s]):c.getDate();if(y>function(t,e){return new Date(e,t+1,0).getDate()}(f,p))throw"";var g=u>-1&&u<o.length?h(o[u]):0;if(g>23)throw"";var m=l>-1&&l<o.length?h(o[l]):0;if(m>59)throw"";var v=d>-1&&d<o.length?h(o[d]):0;if(v>59)throw"";return new Date(p,f,y,g,m,v)}catch(e){throw 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 n=e.length>1?h(e[1]):0;if(n>59)throw"";var o=e.length>1?h(e[1]):0;if(o>59)throw"";return new Date(0,0,0,r,n,o)}catch(e){throw t+" is not a valid time."}};var p=/\[([^\]]+)]|y{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(),n=t.getMonth()+1,o=t.getDate(),i=t.getHours(),s=t.getMinutes(),u=t.getSeconds(),l=i%12||12,d=i>11,c={yyyy:r.toString(),MMMM:a.getLongMonthName(n),MMM:a.getShortMonthName(n),MM:n<10?"0"+n:n.toString(),M:n.toString(),dd:o<10?"0"+o:o.toString(),d:o.toString(),HH:i<10?"0"+i:i.toString(),H:i.toString(),hh:l<10?"0"+l:l.toString(),h:l.toString(),tt:d?"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||c[t]}))},t.numberToStr=function(t,e){return e=e||a.getLocaleSettings().decimalSeparator,t.toString().replace(".",e)}}(u||(u={}));var c,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=(c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},c(t,e)},function(t,e){function r(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),y=function(){return y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y.apply(this,arguments)},g=function(t){function e(e,r){var n=t.call(this,r)||this;return n.status=e,n}return f(e,t),e}(Error),m=function(){function t(){this.defaultHeaders={},this.customPayload=void 0}return 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,n,o){var i=(o=o||{}).dataType||"json",s=o.contentType||"form-data"!==i?"application/json":null;n&&"form-data"!=i&&this.customPayload&&(n.data=u.assignDeep(n.data||{},this.customPayload));var a=new("onload"in new XMLHttpRequest?XMLHttpRequest:window.XDomainRequest),d={method:e,url:r,headers:y(y({},this.defaultHeaders),o.headers||{}),queryParams:o.queryParams||{},data:n};s&&(d.headers["Content-Type"]=s);var c=new l(a,d);this.beforeEachRequest&&(console.warn("HttpClient: 'beforeEachRequest' is deprecated and will be removed in future updates.\n Use 'onRequest' instead"),this.beforeEachRequest(c)),this.onRequest&&this.onRequest(c);var h=c.data&&"string"!=typeof c.data&&"json"==i?JSON.stringify(c.data):c.data;return c.open(),new p(c,new Promise((function(e,n){o.responseType&&(a.responseType=o.responseType),a.onreadystatechange=function(){if(4==a.readyState){var o=a.getResponseHeader("Content-Type")||"",i=a.status;if(i>=400){("arraybuffer"===a.responseType||"blob"===a.responseType?t.decodeArrayBuffer(a.response):Promise.resolve(a.responseText)).then((function(t){var e=0==o.indexOf("application/json")?JSON.parse(t):t,s=e.message||(404==i?"No such endpoint: "+r:e);n(new g(i,s))}))}else{var s="arraybuffer"===a.responseType||"blob"===a.responseType?a.response:0==o.indexOf("application/json")?JSON.parse(a.responseText):a.responseText;e(s)}}},a.send(h)})))},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 n=t.createEntity(this);n.loadFromData(t,e.ents[r]),this.subEntities.push(n)}if(this.attributes=new Array,e.attrs)for(r=0;r<e.attrs.length;r++){var o=t.createEntityAttr(this);o.loadFromData(t,e.attrs[r]),this.attributes.push(o)}}},t.prototype.scan=function(t,e){var r={stop:!1},n=function(o){if(e&&e(o,r),o.attributes)for(var i=o.attributes.length,s=0;s<i&&!r.stop;s++){var a=o.attributes[s];if(t&&t(a,r),r.stop)return}if(o.subEntities){var u=o.subEntities.length;for(s=0;s<u&&!r.stop;s++)n(o.subEntities[s])}};n(this)},t.prototype.getFirstPrimaryAttr=function(){return this.getPrimaryAttrs()[0]},t.prototype.getPrimaryAttrs=function(){return this.attributes.filter((function(t){return t.isPrimaryKey}))},t}(),b=function(){function t(t){this.id="",this.caption="{Unrecognized attribute}",this.dataType=n.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=o.Data}return t.prototype.loadFromData=function(t,e){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,this.defaultValue=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}(),x=function(){function t(){this.id="",this.tag=s.Unknown,this.resType=n.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,n=this.values;r<n.length;r++){var o=n[r];t.indexOf(o.id)>=0&&(e+=o.text+",")}else for(var i=0,s=this.values;i<s.length;i++){(o=s[i]).id===t&&(e+=o.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 b(t)},t.prototype.createValueEditor=function(){return new x},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 o in t.displayFormats){var i=n[o],s=t.displayFormats[o]||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 n=r[e];if(n.id===t)return n}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,n;if(t.attributes){var o=t.attributes.length;for(r=0;r<o;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(n=this.getEntityAttrById(t.subEntities[r],e))return n}return null},t.prototype.listByEntityWithFilter=function(t,e){var r,n=new Array,o=null;if(t.subEntities)for(var i=t.subEntities.length,s=0;s<i;s++){if(o=t.subEntities[s],!e||e(o,null))(r=a.getText("Entities",o.name))||(r=o.caption),(h=u.assign(this.createEntity(),{id:o.name,text:r,items:[],isEntity:!0})).items=this.listByEntityWithFilter(o,e),h.items.length>0&&n.push(h)}var l=null;if(t.attributes)for(var d=t.attributes.length,c=0;c<d;c++)if(l=t.attributes[c],!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});n.push(h)}return n},t.prototype.listByEntity=function(t,e,r){e=e||{};var n,o=[],i=[],s=null;if(t.subEntities)for(var l=t.subEntities.length,d=0;d<l;d++)if(s=t.subEntities[d],!r||r(s,null)){n=a.getText("Entities",s.name)||s.caption;var c=u.assign(this.createEntity(),{id:s.name,text:n,items:[],isEntity:!0,description:s.description}),h=u.assign({},e);h.includeRootData=!1,c.items=this.listByEntity(s,h,r),c.items.length>0&&o.push(c)}var p=null;if(t.attributes)for(var f=t.attributes.length,y=0;y<f;y++)p=t.attributes[y],r&&!r(t,p)||(n=a.getText("Attributes",p.id)||p.caption,i.push(u.assign(this.createEntityAttr(t),{id:p.id,text:n,dataType:p.dataType,lookupAttr:p.lookupAttr,description:p.description})));var g,m=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(o.sort(m),i.sort(m)),g=e.attrPlacement&&0!=e.attrPlacement?i.concat(o):o.concat(i),2==e.attrPlacement&&g.sort(m),e.includeRootData?((n=a.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:g}):g},t.prototype.clear=function(){this.rootEntity=this.createEntity(),this.editors=[],this.version=""},t.prototype.addDefaultValueEditors=function(){this.addOrUpdateValueEditor("_DTE",s.Edit,n.String).defValue="",this.addOrUpdateValueEditor("_DPDE",s.DateTime,n.DateTime),this.addOrUpdateValueEditor("_DPTE",s.DateTime,n.DateTime)},t.prototype.addOrUpdateValueEditor=function(t,e,r){var n=u.findItemById(this.editors,t);return n||((n=this.createValueEditor()).id=t,this.editors.push(n)),n.tag=e,n.resType=r,n},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,n){if(!t)return"";r=r||" ";var o="";if(t.caption&&!n){var i=a.getText("Entities",t.caption);o=i||t.caption}if(t.attributes)for(var s=t.attributes.length,u=0;u<s;u++)if(t.attributes[u].id==e)return o;if(t.subEntities){var l=t.subEntities.length;for(u=0;u<l;u++){var d=t.subEntities[u],c=this.getEntityPathByAttr(d,e,r,!1);if(""!==c)return""!==o&&(c=o+r+c),c}}return""},t.prototype.getAttributeText=function(t,e){var r=a.getText("Attributes",t.id);if(r||(r=t.caption),!e)return r;var n=this.getFullEntityPathByAttr(t.id," ");return(n?e.replace(new RegExp("{attr}","g"),r).replace(new RegExp("{entity}","g"),n):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,n){t(r)&&(n.stop=!0,e=r)}),null),e},t}(),C=function(){return C=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},C.apply(this,arguments)},D=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:!0,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 n=0,o=this.aggregates;n<o.length;n++){var i=o[n];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,n={};if(t)for(var o=0,i=t.columns;o<i.length;o++){var s=i[o],a=e.getValue(s);r&&"string"==typeof a&&(a=a.toLowerCase()),n[s]=a}return n},t.prototype.strictCompare=function(t,e){return t===e},t.prototype.caseInsensitiveCompare=function(t,e){return("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 T,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,n.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},w=function(){function t(){this.items=[],this.mapper={},this._dateColumnIdx=[]}return Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!0,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,[n.Date,n.DateTime,n.Time].indexOf(e.type)>=0&&this._dateColumnIdx.push(r),r},t.prototype.updateDateColumnIdx=function(){this._dateColumnIdx=this.getItems().filter((function(t){return[n.Date,n.DateTime,n.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 '"+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 '"+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 w,this.onUpdate=t.onUpdate,t.columns)for(var e=0,r=t.columns;e<r.length;e++){var n=r[e];this._columns.add(n)}if(t.rows)for(var o=0,i=t.rows;o<i.length;o++){var s=i[o],a=this.createRow(s);this.addRow(a)}this.needTotal=!this._elasticChunks}return Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},enumerable:!0,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:!0,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:!0,configurable:!0}),t.prototype.getRows=function(t){var e=this,r=0,n=this._chunkSize;t&&("page"in t?(r=t.pageSize*(t.page-1),n=t.pageSize):(r=t.offset,n=t.limit));var o=r+n;if(!this.needTotal&&!this.elasticChunks){if(r>=this.total)return Promise.resolve([]);o>this.total&&(o=this.total)}if(this.isInMemory&&o>this.cachedRows.length&&(o=this.cachedRows.length),o<=this.cachedRows.length)return Promise.resolve(this.cachedRows.slice(r,o));if(!this.loader)throw"Loader is not defined. Can't get the rows from "+r+" to "+o;var i=this.needTotal;this.needTotal&&(this.needTotal=!1);var s=this.cachedRows.length,a=o-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()),o>e.cachedRows.length&&(o=e.cachedRows.length),e.elasticChunks)&&(t.table.getCachedCount()<a&&(e.total=e.cachedRows.length));return e.fireUpdated(),e.cachedRows.slice(r,o)}))},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(),n=new Array(this._columns.count),o=t instanceof S?function(e){return t.getValue(e)}:function(e){return t[e]};return t&&this.columns.getItems().forEach((function(t){var i=o(t.id),s=e.columns.getIndex(t.id);n[s]=r.indexOf(s)>=0?e.mapDate(i,t.type):i})),new S(this._columns,n)},t.prototype.mapDate=function(t,e){if(t){var r=new Date(t);return isNaN(r.getTime())&&e==n.Time&&(r=u.strToTime(t)),r}return null},t.prototype.addRow=function(t){var e;if(Array.isArray(t)){var r=t,n=this._columns.getDateColumnIndexes();if(n.length>0)for(var o=0,i=n;o<i.length;o++){var s=i[o];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}(),O=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}(),F=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),n={id:O.newGuid(),callback:e};return r?r.eventCallbacks.push(n):(r={type:t,eventCallbacks:new Array(n)},this.events.push(r)),n.id},t.prototype.unsubscribe=function(t,e){var r=this.getEventRecByType(t);if(r){var n=-1;for(n=0;n<r.eventCallbacks.length&&r.eventCallbacks[n].id!==e;n++);n>=0&&r.eventCallbacks.splice(n,1)}},t.prototype.fire=function(t,e,r,n){if(void 0===r&&(r=0),void 0===n&&(n=!1),!this.silentMode||n){var o=this.getEventRecByType(t);if(o){var i={type:t,source:this.source,data:e},s=function(){for(var t=0,e=o.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 n=r[e];if(n.type==t)return n}return null},t}();!function(t){t.renderLiquidTemplate=function(t,e){var r=t;if(e)for(var n in e){var o=new RegExp("{{"+n+"}}","g");r=r.replace(o,e[n])}return r}}(T||(T={})),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)})},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return GoogleDataConverter}));var _easydata_core__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),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__.b.Date,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.DateTime,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Time].includes(colType)?eval("new "+value):value},GoogleDataConverter.prototype.getValue=function(t,e){var r=t<this.tableObj.rows.length?this.tableObj.rows[t]:null;if(r){var n=e<this.tableObj.cols.length?r.c[e]:null;if(n)return this.convertValue(n.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 n=this.getNumberOfRows();for(r=0;r<n;r++)t.addRow(this.getRow(r))},GoogleDataConverter.prototype.googleDataTypeToDataType=function(t){switch(t){case"string":default:return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.String;case"number":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Float;case"boolean":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Bool;case"date":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Date;case"datetime":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.DateTime;case"timeofday":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Time}},GoogleDataConverter}()},function(t,e,r){"use strict";r.r(e),r.d(e,"equtils",(function(){return o})),r.d(e,"eqconsts",(function(){return s})),r.d(e,"EqServiceProvider",(function(){return z})),r.d(e,"Tree",(function(){return I})),r.d(e,"EasyQueryDataLoader",(function(){return K})),r.d(e,"GoogleDataConverter",(function(){return Y.a})),r.d(e,"EqAggregatesContainer",(function(){return H})),r.d(e,"DefaultAggregatesCalculator",(function(){return J})),r.d(e,"DataKind",(function(){return d})),r.d(e,"LinkType",(function(){return n})),r.d(e,"CondTag",(function(){return O})),r.d(e,"ConditionPart",(function(){return F})),r.d(e,"ExprTag",(function(){return f})),r.d(e,"EqEditorTag",(function(){return E})),r.d(e,"WidgetGroup",(function(){return k})),r.d(e,"AggrFunction",(function(){return c})),r.d(e,"DataModel",(function(){return S})),r.d(e,"Entity",(function(){return v})),r.d(e,"EntityAttr",(function(){return b})),r.d(e,"Operator",(function(){return y})),r.d(e,"Operand",(function(){return g})),r.d(e,"EqValueEditor",(function(){return p})),r.d(e,"EqAction",(function(){return q})),r.d(e,"EqModelLoader",(function(){return N})),r.d(e,"InMemoryModelStorage",(function(){return X})),r.d(e,"BrowserQueryStorage",(function(){return Q})),r.d(e,"EqContext",(function(){return et})),r.d(e,"Widget",(function(){return rt})),r.d(e,"EqActionResult",(function(){return $})),r.d(e,"SortDirection",(function(){return T})),r.d(e,"QueryColumn",(function(){return M})),r.d(e,"Condition",(function(){return L})),r.d(e,"Expression",(function(){return A})),r.d(e,"InvalidQueryError",(function(){return _})),r.d(e,"Query",(function(){return P})),r.d(e,"QueryChangePart",(function(){return C})),r.d(e,"QueryChangeAction",(function(){return D})),r.d(e,"EqServerExporter",(function(){return Z})),r.d(e,"EqServerModelLoader",(function(){return j})),r.d(e,"EqServerDataFetcher",(function(){return G})),r.d(e,"EqServerQuerySynchronizer",(function(){return U})),r.d(e,"EqServerValueListResolver",(function(){return V})),r.d(e,"EqQueryFileLoader",(function(){return W})),r.d(e,"FormatParser",(function(){return u})),r.d(e,"versionInfo",(function(){return nt})),r.d(e,"i18n",(function(){return a.k}));var n,o,i,s,a=r(0),u=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"}(n||(n={})),(i=o||(o={})).combinePath=function(t,e){var r=t;return null!=r&&r.length>0?("/"!=r.charAt(r.length-1)&&(r+="/"),r+=e):r=e,r},i.strToLinkType=function(t){return"All"==t?n.All:"NotAll"==t?n.NotAll:"Any"==t?n.Any:n.None},i.linkTypeToStr=function(t){return t===n.All?"All":t===n.NotAll?"NotAll":t==n.Any?"Any":"None"},i.parseOperatorFormat=function(t){var e=a.k.getText("Operators",t.id,"format");return e||(e=a.k.getText("Operators",t.id,"displayFormat")),e||(e=t.displayFormat),new u(e).parse()},i.convertValue=function(t,e,r){switch(r){case a.b.String:return t;case a.b.Autoinc,a.b.Byte,a.b.Int32,a.b.Int64,a.b.Word:var n=parseInt(t);return isNaN(n)?"":n.toString();case a.b.Currency,a.b.Float:var o=parseFloat(t);return isNaN(o)?"":o.toString();default:return""}},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"}]}(s||(s={}));var l,d,c=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?[a.b.Autoinc,a.b.Byte,a.b.Currency,a.b.Float,a.b.Int32,a.b.Int64,a.b.Word]:"MIN"===this.id||"MAX"===this.id?[a.b.Autoinc,a.b.BCD,a.b.Byte,a.b.Currency,a.b.Date,a.b.DateTime,a.b.Time,a.b.Float,a.b.Int32,a.b.Int64,a.b.Word]:a.l.getAllDataTypes()},t}(),h=(l=function(t,e){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},l(t,e)},function(t,e){function r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),p=function(t){function e(){return t.call(this)||this}return h(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}(a.j);!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"}(d||(d={}));var f,y=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 g,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 p),e.operands))for(var r=0;r<e.operands.length;r++){var n=new g;n.loadFromData(t,e.operands[r]),e.editor&&(n.editor=t.getEditorById(e.editor)||new p),this.operands.push(n)}},t}(),g=function(){function t(){this.kind=d.Scalar,this.dataType=a.b.Unknown,this.editor=new p,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 p)},t.prototype.copyFrom=function(t){a.l.assign(this,t)},t}(),m=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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),v=function(t){function e(e){var r=t.call(this,e)||this;return r.useInConditions=!1,r.useInResult=!1,r.useInSorting=!1,r}return m(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}(a.h),b=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 m(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}(a.i),x=function(){return x=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},x.apply(this,arguments)},E=x(x({},a.d),{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"}(f||(f={}));var C,D,T,I=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 n=r[e].findNode(t);if(n)return n}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}(),w=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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),S=function(t){function e(){var e=t.call(this)||this;return e.mainEntity=null,e.nullAttribute=new b(null),e.nullOperator=new y,e.operators=new Array,e.rootEntity=new v,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 w(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 n=new y;n.loadFromData(this,e.operators[r]),this.operators.push(n)}if(this.rootEntity.loadFromData(this,e.entroot),this.aggrFunctions=new Array,e.aggrfuncs)for(r=0;r<e.aggrfuncs.length;r++){var o=new c;o.loadFromData(e.aggrfuncs[r]),this.aggrFunctions.push(o)}},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 v(t)},e.prototype.createEntityAttr=function(t){return new b(t)},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,o=null;if(t.subEntities)for(var i=t.subEntities.length,s=0;s<i;s++){if(o=t.subEntities[s],!e||e(o,null))(r=a.k.getText("Entities",o.name))||(r=o.caption),(c=a.l.assign(new v,{id:o.name,text:r,items:[],isEntity:!0})).items=this._listByEntityWithFilter(o,e),c.items.length>0&&n.push(c)}var u=null;if(t.attributes)for(var l=t.attributes.length,d=0;d<l;d++)if(u=t.attributes[d],!e||e(t,u)){(r=a.k.getText("Attributes",u.id))||(r=u.caption);var c=a.l.assign(new v,{id:u.id,text:r,dataType:u.dataType});n.push(c)}return n},e.prototype._listByEntity=function(t,e,r){e=e||{};var n,o=[],i=[],s=null;if(t.subEntities)for(var u=t.subEntities.length,l=0;l<u;l++)if(s=t.subEntities[l],(!r||r(s,null))&&(!1!==e.addUIC&&!1!==s.useInConditions||!1!==e.addUIR&&!1!==s.useInResult||!1!==e.addUIS&&!1!==s.useInSorting)){n=a.k.getText("Entities",s.name)||s.caption;var d=a.l.assign(new v,{id:s.name,text:n,items:[],isEntity:!0,description:s.description}),c=a.l.assign({},e);c.includeRootData=!1,d.items=this._listByEntity(s,c,r),d.items.length>0&&o.push(d)}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=a.k.getText("Attributes",h.id)||h.caption,i.push(a.l.assign(new b(t),{id:h.id,text:n,dataType:h.dataType,lookupAttr:h.lookupAttr,description:h.description})));var y,g=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(o.sort(g),i.sort(g)),y=e.attrPlacement&&0!=e.attrPlacement?i.concat(o):o.concat(i),2==e.attrPlacement&&y.sort(g),e.includeRootData?((n=a.k.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:y}):y},e.prototype.clear=function(){t.prototype.clear.call(this),this.operators=[],this.aggrFunctions=[]},e.prototype.addOrUpdateOperator=function(t){var e=a.l.findItemById(this.operators,t.id);return e||((e=new y).id=t.id,this.operators.push(e)),e.caption=t.caption,e.expr=t.expr||"",e.displayFormat=t.format,e.defaultOperand=new g,e.defaultOperand.kind=t.kind||d.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=a.l.findItemById(this.operators,t);r&&(e||a.l.removeArrayItem(this.operators,r),this.runThroughEntities((function(t,e){a.l.removeArrayItem(t.operators,r.id)})))},e.prototype.getOperatorIdsByDataType=function(t){switch(t){case a.b.String:case a.b.Memo:return"StartsWith,EndsWith,Contains,Equal,InList,NotStartsWith,NotEndsWith,NotContains,NotEqual,NotInList,IsNull,IsNotNull".split(",");case a.b.Guid:return"Equal,NotEqual".split(",");case a.b.Date:case a.b.DateTime:return"DateWithinToday,DateWithinThisWeek,DateWithinPrevWeek,DateWithinThisMonth,DateWithinPrevMonth,DateWithinThisYear,DateWithinPrevYear,DateBeforePrecise,DateAfterPrecise,DatePeriodPrecise,IsNull,IsNotNull".split(",");case a.b.Time:return"TimeBeforePrecise,TimeAfterPrecise,TimePeriodPrecise,IsNull,IsNotNull".split(",");case a.b.Byte:case a.b.Word:case a.b.Int32:case a.b.Int64:case a.b.Float:case a.b.Currency:case a.b.BCD:case a.b.Autoinc:case a.b.Unknown:return"Equal,Between,LessThan,LessOrEqual,GreaterThan,GreaterOrEqual,InList,NotEqual,NotBetween,NotInList,IsNull,IsNotNull".split(",");case a.b.Bool:return"IsTrue,NotTrue".split(",");default:for(var e=[],r=0,n=this.operators;r<n.length;r++){var o=n[r];o.appliedTypes.indexOf(t)>=0&&e.push(o.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 I(t),r=0,n=t.subEntities;r<n.length;r++){var o=n[r];e.addChild(this.createTreeNodeFromEntity(o))}return e},e.prototype.getEntitiesInQuery=function(t){if(t.model.id!==this.id)throw Error("Model mithmatch");for(var e=[],r=0,n=t.getColumns();r<n.length;r++){var o=n[r];o.enabled&&this.addEntityByExpression(e,o.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 n=r[e];if(n.id===t)return n}return null},e.prototype.fillEntitiesByCondtionGroup=function(t,e){for(var r=0,n=e.getConditions();r<n.length;r++){var o=n[r];if(o.isGroup())this.fillEntitiesByCondtionGroup(t,o);else for(var i=0,s=o.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 d=l[u];this.addEntityByExpression(t,d)}}}},e.prototype.addEntityByExpression=function(t,e){if(e.tag===f.EntityAttribute){var r=e.baseAttrId||e.value;if(r){var n=this.getAttributeById(r);n&&n.entity&&a.l.indexOfArrayItem(t,n.entity)<0&&t.push(n.entity)}}},e.prototype.findLink=function(t,e){for(var r=0,n=this.links;r<n.length;r++){var o=n[r];if(o.entityFrom==t&&o.entityTo==e)return o}return null},e.prototype.getLinksByEntity=function(t){for(var e=[],r=0,n=this.links;r<n.length;r++){var o=n[r];o.entityFrom!=t&&o.entityTo!=t||e.push(o)}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,n,o){return t.prototype.getEntityPathByAttr.call(this,e,r,n,o)},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 n=t.subEntities.length;for(r=0;r<n;r++){var o=this.getFirstUICAttrInEntity(t.subEntities[r]);if(o)return o}}}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,n){t(r)&&(n.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=a.k.getText("AggregateFunctions",t),r=e?e.caption:a.k.getText("Aggr"+t.replace(" ","")+"_Caption");if(r)return r;var n=a.l.findItemById(this.aggrFunctions,t);return n&&n.caption?n.caption:t},e.prototype.getAggrFunctionFormat=function(t){var e=a.k.getText("AggregateFunctions",t),r=e?e.displayFormat:a.k.getText("Aggr"+t.replace(" ","")+"_Format");if(r)return r;var n=a.l.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 g;e&&e.defaultOperand?(n.copyFrom(e.defaultOperand),n.defValue||(n.defValue=""),n.defText||(n.defText="")):(n.kind=d.Scalar,n.dataType=t.dataType,n.defValue="",n.defText="",n.editor=null);var o=n;return o.dataType===a.b.Unknown&&t&&(o.dataType=t.dataType),e&&r>=0&&e.operands&&e.operands[r-1]&&(o=a.l.assign(o,e.operands[r-1])),o.editor||(n.editor?o.editor=n.editor:n.kind===d.Query?o.editor.tag=E.SubQuery:t&&t.defaultEditor?o.editor=t.defaultEditor:o.dataType===a.b.Date||o.dataType===a.b.DateTime||o.dataType===a.b.Time?o.editor.tag=E.DateTime:o.editor.tag=E.Edit),o},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(a.l.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(a.l.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}(a.g),A=function(){function t(t){var e=this;this.parent=t,this.tag=f.Constant,this.kind=d.Scalar,this.dataType=a.b.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=d.Attribute,this._value=r.id,this.text=r.txt),void 0!==r.dtype&&(this.dataType=r.dtype),this.tag==f.EntityAttribute||this.tag==f.ParentEntityAttribute)this.kind=d.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 n=0;n<r.args.length;n++){var o=new t(this.parent);o.loadFromData(e,r.args[n]),this.args.push(o)}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==f.EntityAttribute||this.tag==f.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:!0,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 n=this.value;if(this.kind==d.Attribute&&t){var o=this.getModel().getAttributeById(t);if(!o)throw"No such entity attribute:"+t;this.dataType=o.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,n)},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 e=o.convertValue(t.value,t.dataType,this.dataType);this.setContent(e.length?e: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"}(C||(C={})),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"}(D||(D={})),function(t){t[t.None=0]="None",t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(T||(T={}));var O,F,M=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._id=a.l.generateId("col"),this.caption="",this.sorting=T.None,this.sortIndex=-1,this.expr=new A(this),this.blockId=""}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,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===a.b.Unknown){var t=null;if(this.expr.func){if("COUNT"==this.expr.func||"CNTDST"==this.expr.func)return a.b.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),void 0!==this.sorting&&this.sorting!=T.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?C.SortingColumns:C.Columns,action:D.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"}(O||(O={})),function(t){t[t.EntityAttr=2]="EntityAttr",t[t.Operator=4]="Operator",t[t.Value=8]="Value",t[t.All=14]="All"}(F||(F={}));var k,q,L=function(){function t(t,e){this.query=t,this.linkType=n.All,this.parent=null,this._id=a.l.generateId("cond"),this.justAdded=!1,this.tag=e||O.Unknown,this.enabled=!0,this.operatorId="",this.blockId="",this.expressions=new Array,this.conditions=new Array}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.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:!0,configurable:!0}),t.prototype.getQuery=function(){return this.query},t.prototype.getModel=function(){return this.query.getModel()},t.prototype.getParent=function(){return this.parent},t.prototype.setParent=function(t){this.parent=t},t.prototype.getConditions=function(){return this.conditions},t.prototype.isEmpty=function(){return 0===this.conditions.length},t.prototype.isGroup=function(){return this.tag==O.Group||null==this.parent},t.prototype.getLevel=function(){var t=this.getParent();return t?t.getLevel()+1:0},t.prototype.isReadOnly=function(){return!1},t.prototype.setReadOnly=function(t){},t.prototype.isParameterized=function(){return!1},t.prototype.setParameterized=function(t){},t.prototype.isInJoin=function(){return!1},t.prototype.setInJoin=function(t){},t.prototype.clearConditions=function(){this.conditions=[]},t.prototype.addCondition=function(t){return t.setParent(this),this.conditions.push(t)},t.prototype.removeConditionAt=function(t){this.conditions.splice(t,1)},t.prototype.loadFromData=function(t,e){if(e){if(this.tag=e.tag,this.tag||(this.tag=!this.parent||this.conditions.length>0?O.Group:O.Simple),void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.disabled&&(this.enabled=!e.disabled),this.tag==O.Simple&&(this.operatorId=e.op,e.exprs))for(var r=0;r<e.exprs.length;r++){var n=new A(this);n.loadFromData(t,e.exprs[r]),this.expressions.push(n)}this.linkType=e.linking}},t.prototype.saveToData=function(){var t={};if(t.tag=this.tag,this.enabled||(t.enabled=this.enabled),this.tag==O.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==O.Group&&(t.linking=this.linkType),t},t.prototype.fireChangedEvent=function(t){void 0===t&&(t=F.All),this.query.fireChangedEvent({part:C.Conditions,action:D.Modify,changee:this,condPart:t})},t.prototype.getExpressionIndex=function(t){return this.expressions.indexOf(t,0)},t.prototype.expressionChanged=function(t,e){0==t.getIndex()&&t.tag==f.EntityAttribute&&this.tuneOperatorForAttr(t.value)},t.prototype.getOperatorId=function(){return this.operatorId},t.prototype.setOperatorId=function(t,e){void 0===e&&(e=!1);var r=this.operatorId;if(this.operatorId=t,!e){var n=this.getModel(),o=n.getOperatorById(t),i=this.expressions[0].value,s=n.getAttributeById(i);this.tuneValueExpressions(s,o,s.id,r)}},t.prototype.tuneOperatorForAttr=function(t){var e=this.getModel(),r=this.expressions[0].value,n=e.getAttributeById(r);if(null!=n){var o=this.getModel().getDefaultOperatorForAttr(n),i=this.operatorId;this.operatorId=o.id,this.tuneValueExpressions(n,o,t,i)}},t.prototype.tuneValueExpressions=function(t,e,r,n){var o=this.getModel();if(e){var i=this.expressions.length,s=(r&&o.getAttributeById(r),null);if(n&&(s=o.getOperatorById(n)),s&&s.paramCount==e.paramCount){for(var u=1;u<e.paramCount;){var l=o.getOperand(t,s,u);(y=o.getOperand(t,e,u)).dataType==a.b.Unknown&&(y.dataType=t.dataType);var d=y.editor&&y.editor.tag!==a.d.Unknown?y.editor:t.defaultEditor&&t.defaultEditor.tag!==a.d.Unknown?t.defaultEditor:new p;if(u>=i){var c=this.createValueExpr(y);this.expressions.push(c)}else{var h=this.expressions[u],f=this.createValueExpr(y);this.areCompitableEditors(l.editor,d)&&f.tryCopyValueFrom(h),this.expressions[u]=f}u++}i>u&&this.expressions.splice(u,i-u)}else{this.expressions.splice(1,this.expressions.length-1);for(u=1;u<e.paramCount;u++){var y;(y=o.getOperand(t,e,u)).dataType==a.b.Unknown&&(y.dataType=t.dataType);c=this.createValueExpr(y);this.expressions.push(c)}}}},t.prototype.areCompitableEditors=function(t,e){return e.tag!=E.CustomList&&e.tag!=E.List&&e.tag!=E.SqlList&&e.tag!=a.d.Unknown},t.prototype.addExpressionByOperand=function(t,e){void 0===e&&(e=null);var r=this.createValueExpr(t,e);return this.expressions.push(r),r},t.prototype.createValueExpr=function(t,e){void 0===e&&(e=null);var r=null==e,n=e||t.defValue,o=e||t.defText,i=new A(this);if(t.kind===d.Query)i.tag=f.Query,i.dataType=t.dataType,i.kind=t.kind,i.setContent(n,o,!0);else if(t.kind===d.Attribute){if(!r){var s=this.getModel().getFirstAttributeByFilter((function(e){return 1==e.useInConditions&&(!t.dataType||e.dataType==t.dataType)}));n=s?s.id:null}i.tag=f.EntityAttribute,i.kind=t.kind,i.dataType=t.dataType,i.setContent(n,o,!0)}else r&&(n=t.defValue&&""!=t.defValue?t.defValue:t.editor&&t.editor.defValue?t.editor.defValue:"",t.editor&&(o=t.editor.getValueText(n))),i.tag=f.Constant,i.dataType=t.dataType,i.kind=t.kind,i.setContent(n,o,!0),i._isDefaultValue=r;return i},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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),_=function(t){function e(r){var n=t.call(this,r)||this;return Error.captureStackTrace&&Error.captureStackTrace(n,e),n.name="InvalidQueryError",n}return R(e,t),e}(Error),P=function(){function t(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 a.e(this),this.root=new L(this,O.Group),this.extraConditions=new L(this,O.Group),this.columns=new Array,this.justsorted=new Array,this.id||this.regenerateId(),this.setDefaultName(),this.description="",this.model=t||new S,e&&this.loadFromData(e),this.attributeExprTag=r&&r.attrTag||f.EntityAttribute,this.clientListRequestHandler=r?r.clientListRequestHandler:new Array,this.serverListRequestHandler=r?r.serverListRequestHandler:new Array,this.timezoneOffset=(new Date).getTimezoneOffset(),this.aggrSettings=new a.a(this),r&&(this.parentQuery=r.parent),this.addChangedCallback((function(t){t.data&&(t.data.part&C.Columns)>0&&!t.data.aggregation&&n._enableAggregation&&n.updateAggregationSettings()&&n.fireChangedEvent({part:C.Aggregation})}))}return t.prototype.isModified=function(){return this._isModified},t.prototype.resetModified=function(){this._isModified=!1},Object.defineProperty(t.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==f.AggregateFunction}))}this._enableAggregation||this.aggrSettings.clear()},enumerable:!0,configurable:!0}),t.prototype.updateAggregationSettings=function(){for(var t=!1,e=this.getAggregationSettings(),r=e.groups.length-1;r>=0;r--){for(var n=e.groups[r],o=function(e){var r=n.columns[e];i.columns.find((function(t){return t.id===r}))||(n.columns.splice(e,1),t=!0)},i=this,s=n.columns.length-1;s>=0;s--)o(s);0==n.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},t.prototype.createSubQuery=function(){return new t(this.model)},t.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")},t.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==f.AggregateFunction}));if(r.length){for(var n=t.columns.filter((function(t){return t.enabled&&t.expr.tag==f.EntityAttribute})),o=[],i=0,s=r;i<s.length;i++){var u=s[i];o.push({id:u.id,func:u.expr.func}),t.changeColumnType(u,f.EntityAttribute)}for(var l=0,d=o;l<d.length;l++){var c=d[l];e.addAggregateColumn(c.id,c.func)}for(var h=0,p=n;h<p.length;h++){u=p[h];e.addGroup({columns:[u.id],name:u.caption})}e.addGrandTotals(),t.fireChangedEvent({part:C.Columns,wasModified:!1})}else{var y=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==f.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===a.b.Currency}))[0],g=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==f.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===a.b.String}))[0];if(!y&&!e.hasAggregates()||!g)return;e.addGrandTotals().addAggregateColumn(y.id,"SUM").addGroup({columns:[g.id],name:"Default"})}}))},t.prototype.processQueryForAggregation=function(t){void 0===t&&(t=!1);var e=this.getAggregationSettings().getGroups();if(e.length>0){for(var r=e[e.length-1].columns,n=[],o=[],i=0,s=this.getColumns();i<s.length;i++){var a=s[i];r.indexOf(a.id)>=0?n.push(a):a.sorting!=T.None&&o.push(a)}var u=0;n.forEach((function(t){t.sorting==T.None&&(t.sorting=T.Ascending),t.sortIndex=u++})),o.forEach((function(t){t.sortIndex=u++})),t||this.fireChangedEvent({part:C.Columns,aggregation:!0,wasModified:!1})}},t.prototype.getAggregationSettings=function(){return this.aggrSettings},t.prototype.getColumnIds=function(t,e){return e=e||t,this.columns.slice(t,e-t+1).map((function(t){return t.id}))},t.prototype.validateColumns=function(t){for(var e=this.columns.filter((function(t){return t.enabled})).map((function(t){return t.id})),r=-1,n=0,o=t;n<o.length;n++){var i=o[n],s=e.indexOf(i);if(s<0)return!1;if(r>s)return!1;r=s}return!0},t.prototype.validateAggregate=function(t,e){var r=this.columns.filter((function(e){return e.enabled&&e.id===t}))[0],n=this.model.findAggrFunctionById(e);return!(!n||!r||n.appliedTypes.indexOf(r.expr.dataType)<0)},t.prototype.isEx=function(){return!1},t.prototype.reset=function(t){void 0===t&&(t=!0),t&&this.clear(),this.regenerateId(),this.setDefaultName(),this._isModified=!1,this.isNewbie=!0},t.prototype.hasEnabledAggrColumns=function(){return this.columns.filter((function(t){return t.enabled&&t.expr.tag===f.AggregateFunction})).length>0},t.prototype.setDefaultName=function(){return this.setName(a.k.getText("NewQueryName")),this.getName()},t.prototype.validate=function(t){t=t||{};var e="EntityAttribute isn't declared in the model: ";if(!this.model)throw new _("Model is not declared");if(this.columns)for(var r=0,n=this.columns;r<n.length;r++){var o=n[r];if(o.expr.tag==f.EntityAttribute||o.expr.tag===f.ParentEntityAttribute){if(!this.model.getAttributeById(o.expr.value))throw new _(e+o.expr.value)}else if(o.expr.tag===f.AggregateFunction){if(!this.model.getAttributeById(o.expr.args[0].value))throw new _(e+o.expr.args[0].value)}else if(o.expr.tag!==f.CustomSql)throw new _("The expression has wrond tag: "+o.expr.tag)}this.root&&this.root.getConditions()&&this.validateConditionGroup(this.root,t)},t.prototype.getAggregatedColumns=function(){return this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===f.AggregateFunction}))},t.prototype.tryValidate=function(t){try{return this.validate(t),!0}catch(t){if(t instanceof _)return!1;throw t}},t.prototype.validateConditionGroup=function(t,e){if(t.isGroup())for(var r=0,n=t.getConditions();r<n.length;r++){var o=n[r];o.enabled&&this.validateConditionGroup(o,e)}else if(t.expressions[0].tag===f.EntityAttribute){var i=t.expressions[0].value;if(!this.model.getAttributeById(i))throw new _("EntityAttribute isn't declared in the model: "+i);if(!e.checkExpressions)return;for(var s=1;s<t.expressions.length;s++){var u=t.expressions[s];if(u.tag===f.Constant&&a.l.isNumericType(u.dataType)){if(!u.value)continue;for(var l=0,c=u.kind===d.List?u.value.split(/\s*,\s*/):[u.value];l<c.length;l++){var h=c[l],p=+h;if(isNaN(p))throw new _("Expression constant is NaN in condition:"+t.id);if(a.l.isIntType(u.dataType)&&p!=parseInt(h,10))throw new _("Expression constant is wrong interger in condition: "+t.id)}}}}},t.prototype.loadFromDataOrJson=function(t,e){t&&("string"==typeof t?this.loadFromJson(t,e):this.loadFromData(t,e))},t.prototype.loadFromJson=function(t,e){var r=JSON.parse(t);this.loadFromData(r,e)},t.prototype.loadFromData=function(t,e){var r=this;e=a.l.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 o=t.root.conds[n];if(!o.conds||this.isEx()){var i=this.createCondition();i.loadFromData(this.model,o),this.root.addCondition(i)}else console.error("Community version doesn't support working with groups.")}if(this.name=t.name,this.description=t.desc,this.justsorted=[],t.justsortcols)for(n=0;n<t.justsortcols.length;n++){(s=this.createColumn(!0)).loadFromData(this.model,t.justsortcols[n]),this.justsorted.push(s)}if(t.cols)for(n=0;n<t.cols.length;n++){var s;(s=this.createColumn()).loadFromData(this.model,t.cols[n]),this.columns.push(s)}if(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 d=l[u];this.addDrillDown().loadFromData(d)}}e.changeStatus&&(this.isNewbie=!1,this._isModified=!1),e.validate&&this.validate()},t.prototype.addDrillDown=function(){var t=this.model.createQuery();return t.parentQuery=this,this.drillDowns.push(t),t},t.prototype.getDrillDowns=function(){return this.drillDowns},t.prototype.getParentQuery=function(){return this.parentQuery},t.prototype.findColumnById=function(t){for(var e=0,r=this.columns;e<r.length;e++){var n=r[e];if(n.id===t)return n}return null},t.prototype.getModel=function(){return this.model},t.prototype.setModel=function(t){this.model=t},t.prototype.loadModelData=function(t){this.model.setData(t)},t.prototype.toJSON=function(){return JSON.stringify(this.toJSONData())},t.prototype.toJSONData=function(){var t=this,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=[];for(r=0;r<this.justsorted.length;r++)e.justsortcols.push(this.justsorted[r].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 n=e.getConditions(),o=0;o<n.length;o++)!n[o].isGroup()||t.isEx()?r.conds.push(n[o].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 o=0,i=this.drillDowns;o<i.length;o++){var s=i[o];e.dds.push(s.toJSONData())}}return e.timezoneOffset=this.timezoneOffset,e.locale=a.k.getCurrentLocale(),e},t.prototype.isEmptyConditions=function(){return this.root.isEmpty()},t.prototype.isEmptyColumns=function(){return!this.columns||0===this.columns.length},t.prototype.isEmpty=function(){return this.isEmptyColumns()&&this.isEmptyConditions()},t.prototype.clear=function(){this._enableAggregation=!1,this.aggrSettings.clear(),this.clearColumns(),this.clearConditions(),this.clearExtraConditions(),this.innerData={},this.extraData={}},t.prototype.clearColumns=function(){this.columns=[],this.justsorted=[]},t.prototype.clearConditions=function(){this.root.clearConditions(),this.root.linkType=n.All,this.root.enabled=!0},t.prototype.clearExtraConditions=function(){this.extraConditions.clearConditions()},t.prototype.clearDrillDowns=function(){this.drillDowns=[]},t.prototype.getId=function(){return this.id},t.prototype.setId=function(t){this.id=t},t.prototype.regenerateId=function(){this.id=a.l.generateId("quer")},t.prototype.getName=function(){return this.name},t.prototype.setName=function(t){this.name=t},t.prototype.getDescription=function(){return this.description},t.prototype.setDescription=function(t){this.description=t},t.prototype.getColumns=function(){return this.columns},t.prototype.getUsedInTotalsColumns=function(){if(0===this.getAggregatedColumns().length)return[];var t=this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===f.EntityAttribute}));return t.length&&t.pop(),t},t.prototype.getJustSortedColumns=function(){return this.justsorted},t.prototype.getSortedColumns=function(){for(var t=new Array,e=this.getColumns().concat(this.getJustSortedColumns()),r=0;r<e.length;r++){var n=e[r];n.sortIndex>=0&&t.push(n)}return t.sort((function(t,e){return t.sortIndex-e.sortIndex})),t},t.prototype.getColumnSortIndex=function(t){if(t.sorting!=T.None){if(t.sortIndex<0){var e=this.getColumns().concat(this.getJustSortedColumns());return a.l.indexOfArrayItem(e,t)}return t.sortIndex}return-1},t.prototype.createColumn=function(t){return void 0===t&&(t=!1),new M(this,t)},t.prototype.getColumnById=function(t){return a.l.findItemById(this.columns,t)},t.prototype.addColumn=function(t,e){var r,n=t.justsorted?this.justsorted:this.columns;if(t.column)r=t.column;else{r=this.createColumn(t.justsorted);var o=void 0;if(t.attribute)o=t.attribute;else{if(!t.attributeId)throw new Error("Not enought data: addColumn");if(!(o=this.model.getAttributeById(t.attributeId)))throw new Error("Incorrect attribute id ("+t.attributeId+"): addColumn")}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=f.CustomSql,r.expr.baseAttrId=o.id,r.expr.sql=t.cusomtSql,r.expr.kind=d.Query,r.expr.dataType=a.b.Unknown;else if(t.aggrFuncId){var i=t.aggrFuncId;r.caption=o.caption+" "+this.model.getAggrFunctionCaption(t.aggrFuncId),r.expr.tag=f.AggregateFunction,r.expr.func=t.aggrFuncId,r.expr.kind=d.Scalar,r.expr.dataType="COUNT"==i||"CNTDST"==i?4:o.dataType,r.expr.distinct=!1;var s=new A(r);s.setValue(o.id,!0),s.tag=f.EntityAttribute,s.dataType=o.dataType,r.expr.args.push(s)}else r.caption=o.caption,r.expr.setValue(o.id,!0),r.expr.tag=f.EntityAttribute,r.expr.dataType=o.dataType;r.caption=t.caption||r.caption,r.sorting=t.sorting||T.None,r.sortIndex=t.sortIndex||-1,r.enabled=a.l.getIfDefined(t.enabled,!0),r.setReadOnly(a.l.getIfDefined(t.readonly,!1))}return t.index&&t.index>=0&&t.index<n.length?n.splice(t.index,0,r):n.push(r),r},t.prototype.addColumnObj=function(t,e,r){var n=this.columns;void 0===t.length?"number"==typeof e?n.splice(e,0,t):n.push(t):"number"==typeof e?n.push.apply(n,[e,0].concat(t)):n.push.apply(n,[].concat(t))},t.prototype.changeColumnType=function(t,e,r){if(!t.isJustSorted())if(r=r||{},t.caption=void 0!==r.caption?r.caption:"",e===f.AggregateFunction){if(!r.funcId)throw Error('"funcId" argument is not defined');if(t.expr.tag==f.AggregateFunction)return void(t.expr.func=r.funcId);(u=new A(t)).tag=f.AggregateFunction,u.func=r.funcId,u.distinct=!1,u.dataType="COUNT"==r.funcId||"CNTDST"==r.funcId?4:t.expr.dataType;var n=new A(t);n.loadFromData(this.model,t.expr.saveToData()),u.args.push(n),t.expr=u}else if(e===f.CustomSql){var o=t.expr.tag==f.AggregateFunction?t.expr.args[0].value:t.expr.value,i="";this.model&&(i=this.model.getAttributeById(o).expr);var s=new A(t);s.tag=f.CustomSql,s.dataType=a.b.String,s.sql=i,s.baseAttrId=o,t.expr=s}else if(e===f.EntityAttribute){if(t.expr.tag===f.EntityAttribute||t.expr.tag===f.ParentEntityAttribute)return;var u,l=t.expr.tag===f.CustomSql?t.expr.baseAttrId:t.expr.args[0].value,d=this.model.getAttributeById(l);(u=new A(t)).tag=f.EntityAttribute,u.dataType=null!=d?d.dataType:a.b.Unknown,u.setValue(l,!0),t.expr=u}},t.prototype.moveColumn=function(t,e){var r=this.getColumns();a.l.moveArrayItem(r,t,e)},t.prototype.removeColumn=function(t,e){var r=t.isJustSorted()?this.getJustSortedColumns():this.getColumns();a.l.removeArrayItem(r,t)},t.prototype.addConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},t.prototype.addExtraConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},t.prototype.createCondition=function(t){return void 0===t&&(t=O.Simple),new L(this,t)},t.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=a.l.getIfDefined(t.enabled,!0),n.setReadOnly(a.l.getIfDefined(t.readonly,!1)),n},t.prototype.addSimpleExtraCondition=function(t){return t.parent=t.parent||this.extraConditions,this.addSimpleCondition(t)},t.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(O.Simple);n.setOperatorId(e.id,!0);var o=new A(n);o.setValue(t.id,!0),o.tag=this.attributeExprTag,o.kind=d.Attribute,o.dataType=t.dataType,n.expressions.push(o);var i=this.getModel(),s=e.paramCount,u=a.l.fillArray(new Array(s-1),null);null!=r&&(Array.isArray(r)?a.l.copyArrayTo(r,u):s>0&&(u[0]=r));for(var l=u.length,c=0;c<l;c++){var h=i.getOperand(t,e,c+1);n.addExpressionByOperand(h,u[c])}return n},t.prototype.removeColumns=function(t,e){var r=t.filter((function(t){return t.isJustSorted()})),n=t.filter((function(t){return!t.isJustSorted()}));function o(t,e){for(var r=e.length,n=0;n<r;n++){var o=t.indexOf(e[n]);o>=0&&t.splice(o,1)}}n.length>0&&o(this.getColumns(),n),r.length>0&&o(this.getJustSortedColumns(),r)},t.prototype.fireProcessEvent=function(t){this.eventEmitter.fire("query.process",t)},t.prototype.fireChangedEvent=function(t,e,r){t=t||{part:C.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 n=t||{part:C.All};this.eventEmitter.fire("query.change",n,t.postpone||0)},t.prototype.fireColumnsChangedEvent=function(t,e,r){void 0===r&&(r=!1),this.fireChangedEvent({part:r?C.SortingColumns:C.Columns,action:t,changee:e})},t.prototype.fireConditionsChangedEvent=function(t,e){this.fireChangedEvent({part:C.Conditions,action:t,changee:e})},t.prototype.runThroughConditions=function(t){var e=function(r){for(var n=0;n<r.getConditions().length;n++){var o=r.getConditions()[n];o.isGroup()?e(o):t&&t(o)}};e(this.getRootCondition())},t.prototype.getOneValueForAttr=function(t){var e=null;return this.runThroughConditions((function(r){if(r.enabled){var n=r.expressions[0],o=r.getOperatorId();n.value!=t||!r.expressions[1]||"Equal"!=o&&"InList"!=o&&"StartsWith"!=o||(e=r.expressions[1].value)}})),e},t.prototype.getRootCondition=function(){return this.root},t.prototype.addProcessCallback=function(t){return this.eventEmitter.subscribe("query.process",t)},t.prototype.removeProcessCallback=function(t){this.eventEmitter.unsubscribe("query.process",t)},t.prototype.addChangedCallback=function(t){return this.eventEmitter.subscribe("query.change",t)},t.prototype.removeChangedCallback=function(t){this.eventEmitter.unsubscribe("query.change",t)},t.prototype.getConditionsText=function(){var t=this,e=this.getModel();if(!e)return"";var r=function(i){var s,u,l="",c="Conj"+o.linkTypeToStr(i.linkType),h=a.k.getText(c);for(u=0;u<i.getConditions().length;u++){s="";var p=i.getConditions()[u];if(p.enabled||void 0===p.enabled)if(p.isGroup())(s=r(p))&&(s="("+s+")");else for(var y=p.getOperatorId(),g=e.getOperatorById(y),m=o.parseOperatorFormat(g),v=m.length,b=0;b<v;b++){var x=m[b],E=x.text;if("expression"==x.type){var C=p.expressions[x.index];if(C.kind==d.Attribute||C.tag==f.EntityAttribute){var D=e.getAttributeById(C.value);E=e.getAttributeText(D,"{entity} {attr}")}else if(E=C.getText(),t.model.isDateMacro(E)||t.model.isTimeMacro(E)){var T=E.substring(3,E.length-2);E=a.k.getText(T)||E}}b>0&&(s+=" "),s+=E}s&&(u>0&&l&&(l+=" "+h+" "),l+=s)}return i.linkType!=n.None&&i.linkType!=n.NotAll||(l="not ( "+l+" )"),l};return r(this.getRootCondition())},t.prototype.getConditionsTextAsHtml=function(){var t=this,e=this.getModel();if(!e)return'<div class="eqjs-query-text"></div>';var r=function(e){if(e.kind==d.Query)return"<"+e.getText()+">";if(e.kind==d.List)return"["+e.getText()+"]";if(e.dataType==a.b.String||e.dataType==a.b.Memo||e.dataType==a.b.FixedChar)return"""+e.getText()+""";var r=e.getText();if(t.model.isDateMacro(r)||t.model.isTimeMacro(r)){var n=r.substring(3,r.length-2);r=a.k.getText(n)||r}return r},i=function(t){var s,u,l="",c="Conj"+o.linkTypeToStr(t.linkType),h='<span class="eqjs-query-text-conj">'+a.k.getText(c)+"</span>";for(u=0;u<t.getConditions().length;u++){s="";var p=t.getConditions()[u];if(p.enabled||void 0===p.enabled)if(p.isGroup())(s=i(p))&&(s="("+s+")");else for(var y=p.getOperatorId(),g=e.getOperatorById(y),m=o.parseOperatorFormat(g),v=m.length,b=0;b<v;b++){var x=m[b],E=x.text;if("expression"==x.type){var C=p.expressions[x.index];if(C.kind==d.Attribute||C.tag==f.EntityAttribute){var D=e.getAttributeById(C.value);E='<span class="eqjs-query-text-attr">'+e.getAttributeText(D,"{entity} {attr}")+"</span>"}else E='<span class="eqjs-query-text-expr">'+r(C)+"</span>"}else"operator"==x.type&&(E='<span class="eqjs-query-text-op">'+E+"</span>");b>0&&(s+=" "),s+=E}s&&(u>0&&l&&(l+=" "+h+" "),l+=s)}return t.linkType!=n.None&&t.linkType!=n.NotAll||(l='<span class="eqjs-query-text-conj">not</span> ( '+l+" )"),l};return'<div class="eqjs-query-text">'+i(this.getRootCondition())+"</div>"},t}(),Q=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 n=localStorage.getItem(e.queryListKey);n&&t(JSON.parse(n)),t([])}catch(t){r(t)}}))},t.prototype.newQuery=function(t){var e=this;return new Promise((function(r,n){var o=new P(e.context.getModel());o.reset(),o.setDefaultName(),t&&(t.query&&o.loadFromData(t.query.toJSONData()),t.queryId&&o.setId(t.queryId),t.name&&o.setName(t.name),t.description&&o.setDescription(t.description)),e._saveQuery(o),r(o.toJSONData())}))},t.prototype.loadQuery=function(t){var e=this;return new Promise((function(r,n){try{var o=localStorage.getItem(e.queryKeyPrefix+"-"+t.queryId);throw o&&r(JSON.parse(o)),new Error("Query is not found: "+t.queryId)}catch(t){n(t)}}))},t.prototype.saveQuery=function(t){var e=this;return new Promise((function(r,n){try{t.modelId||e.context.getModel().getId();var o=t.query||e.context.getQuery();e._saveQuery(o),r(null)}catch(t){n(t)}}))},t.prototype._saveQuery=function(t){var e=[],r=localStorage.getItem(this.queryListKey);r&&(e=JSON.parse(r));var n=a.l.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,n){try{t.modelId||e.context.getModel().getId();var o=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!=o})),localStorage.setItem(e.queryListKey,JSON.stringify(i)),localStorage.removeItem(e.queryKeyPrefix+"-"+o),r()}catch(t){n(t)}}))},t}(),N=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}(),B=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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),j=function(t){function e(e){return t.call(this,e)||this}return B(e,t),e.prototype.init=function(){},e.prototype.sendLoadModelRequest=function(t){var e=this,r=this.getContext(),n=r.getServices().getHttpClient(),o=r.resolveEndpoint("GetModel",{modelId:t.modelId});n.get(o).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}(N),G=function(){function t(t){this.context=t}return t.prototype.fetchData=function(t){var e=t.query||this.context.getQuery(),r=e.getId(),n={options:t.options};void 0!==t.queryId?n.queryId=t.queryId:n.query=e.toJSONData(),t.debug&&(n.debug=t.debug),t.chunk&&(n.chunk=t.chunk),t.data&&(n.data=t.data),void 0!==t.aux&&(n.aux=t.aux);var o=this.context.resolveEndpoint("FetchData",{modelId:e.getModel().getId(),queryId:r});return this.context.getServices().getHttpClient().post(o,n).then((function(t){return t}))},t}(),U=function(){function t(t){this.context=t}return t.prototype.syncQuery=function(t){var e=(t=t||{}).query||this.context.getQuery(),r=t.options||{},n={query:e.toJSONData(),options:r};t.data&&(n.data=t.data);var o=this.context.resolveEndpoint("SyncQuery",{modelId:e.getModel().getId(),queryId:e.getId()});return this.context.getServices().getHttpClient().post(o,n).then((function(t){return t}))},t}(),V=function(){function t(t){this.context=t}return t.prototype.loadValueList=function(t){var e=t.modelId||this.context.getModel().getId(),r=a.l.assign({modelId:e},t.params).editorId,n=this.context.getServices().getHttpClient(),o=this.context.resolveEndpoint("GetValueList",{modelId:e,listId:r}),i={};return t&&t.params&&t.params.queryParams&&(i=t.params.queryParams),n.get(o,{queryParams:i}).then((function(t){if(t&&t.values)return t.values;throw new Error('Wrong response format. No "values" property')}))},t}(),W=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"}),n=this.context.getServices().getHttpClient().post(r,{query:e.toJSONData()}),o=n.getRequest();return n.then((function(e){var r=new Blob([e]),n=o.getXMLHttpRequest().getResponseHeader("Content-Disposition").match(/filename="(.*)"/)[1];if(t.fileName&&(n=t.fileName+n.substring(n.lastIndexOf("."))),window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,n);else{var i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=window.URL.createObjectURL(r),i.download=n,i.click(),window.URL.revokeObjectURL(i.href),document.body.removeChild(i)}}))},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}(),H=function(){function t(t){this.context=t,this.levels={}}return t.prototype.getAggregateData=function(t,e){var r=this;return new Promise((function(n,o){var i=function(t){var i=r.groupKeyToStr(e),s=t.get(i);s?n(s):o("Can't find data for "+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 n=0,o=r.receivedCallbacks;n<o.length;n++){(0,o[n])(r.data)}r.receivedCallbacks=[]},t.prototype.updateAggregateData=function(t,e,r){var n=this.getLevelDesc(t,!0),o=this.groupKeyToStr(e);n.data.set(o,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}(),J=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 H(this.context);var e=this.context.createQuery();e.loadFromData(this.context.getQuery().toJSONData());for(var r=this.context.getQuery().getAggregationSettings(),n=r.getAggregates().map((function(t){return t.colId})),o=e.getColumns().filter((function(t){return n.indexOf(t.id)<0})),i=0;i<o.length;i++)o[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}(),z=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 a.f,this.httpClient.defaultHeaders["x-eqjs-version"]="7.2.0",this.modelResolver=function(t){return new S},this.modelStorageResolver=null,this.queryResolver=function(t){return new P(t.getModel())},this.modelLoaderResolver=function(t){return new j(t)},this.queryStorageResolver=function(t){return new Q(t)},this.querySynchronizerResolver=function(t){return new U(t)},this.vlrResolver=function(t){return new V(t)},this.dataFetcherResolver=function(t){return new G(t)},this.queryFileLoaderResolver=function(t){return new W(t)},this.aggrCalculatoResolver=function(t){return new J(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}(),K=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 o={chunk:t,success:function(n){for(var o=new a.c({loader:e.context.dataLoader,chunkSize:e.context.resultTable.chunkSize}),i=n.resultSet,s=0,u=i.cols;s<u.length;s++){var l=u[s];o.columns.add(l)}o.setTotal(n.meta.totalRecords);for(var d=0,c=i.rows;d<c.length;d++){var h=c[d];o.addRow(h)}var p=0;n.meta&&n.meta.totalRecords&&(p=n.meta.totalRecords),r({table:o,total:p,hasNext:!t.needTotal||t.offset+t.limit<p})},error:function(t){return n(t)}};e.context.debugMode&&(o.debug="Data Chunk. Offset: "+t.offset),e.context.fetchDataChunk(o)})),this.dataLoadPromise},t}(),Y=r(1);!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"}(k||(k={})),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"}(q||(q={}));var $,X=function(){function t(t){this.models=[],t&&a.l.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"}($||($={}));var Z=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",n=t.query||this.context.getQuery(),o=n.getModel().getId(),i={settings:t.settings};void 0!==t.queryId?i.queryId=t.queryId:i.query=n.toJSONData();var s=this.context.resolveEndpoint("ExportResult",{modelId:o,format:r}),a=e.post(s,i,{responseType:this.responseType}),u=a.getRequest();return a.then((function(t){var e=new Blob([t]),r=u.getXMLHttpRequest().getResponseHeader("Content-Disposition").match(/filename="(.*)"/)[1];if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(e,r);else{var n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=window.URL.createObjectURL(e),n.download=r,n.click(),window.URL.revokeObjectURL(n.href),document.body.removeChild(n)}}))},t}(),tt=function(){return tt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},tt.apply(this,arguments)},et=function(){function t(){var t=this;this.servicesInitialized=!1,this.internalListCache={},this.loadModelOnStart=!0,this.loadQueryOnStart=!1,this.useStoredQueryOnFetch=!1,this.debugMode=!1,this.endpointVarsRegex=/\{.*?\}/g,this.elasticPaging=!1,this._predefinedListRequestHandlers={_DSDE:function(e,r){return r(t.getModel().getAllDateMacros().map((function(t){return{id:"${{"+t+"}}",text:a.k.getText(t)}}))),!0},_DSTE:function(e,r){return r(t.getModel().getAllTimeMacros().map((function(t){return{id:"${{"+t+"}}",text:a.k.getText(t)}}))),!0}},this._listRequestHandler=function(e,r){if(null!=e&&e.listName){var n=t.getQuery(),o=a.l.assign({listName:e.listName},e.editorParams),i={},s=/@{{(.+?)}}/;for(var u in o)if(i[u]){var l=o[u].match(s);if(l){var d=n.getOneValueForAttr(l[1]);d||(d=""),i[u]=o[u].replace(s,d)}}var c={listName:i.listName,editorId:e.editorId,queryParams:i},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:c,success:function(n){n&&t.addListToCache(e,n),r(n)},error:function(t){r(null)}})}}},this.baseEndpoint="api/easyquery",this.eqServices=new z(this),this.widgets=new Array,this.eventEmitter=new a.e(this),this.exporters=new Map,this.endpoints=new Map,this.dataLoader=new K(this),this.resultTable=new a.c({loader:this.dataLoader,onUpdate:this.onResultTableUpdate.bind(this)}),this.resultTable.id="ResultTable",this.errorHandlerId=this.addEventListener("error",(function(t,e){e.result=$.Error;var r=e.action?e.action+" error":"Error",n=e.text?e.text:"";e.sourceError&&e.sourceError.message!==n&&(n+="\n"+e.sourceError),console.error(r+": "+n)}))}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 n=new Z(r);return n.setFormat(t,e),n}))},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 n=r.match(this.endpointVarsRegex);if(n)for(var o=0,i=n;o<i.length;o++){var s=i[o],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 ["+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",o.combinePath(t,"models/{modelId}")),this.setEnpointIfNotExist("GetQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SaveQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SyncQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}/sync")),this.setEnpointIfNotExist("NewQuery",o.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("RemoveQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("GetQueryList",o.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("FetchData",o.combinePath(t,"models/{modelId}/fetch")),this.setEnpointIfNotExist("GetValueList",o.combinePath(t,"models/{modelId}/valuelists/{listId}")),this.setEnpointIfNotExist("ExportResult",o.combinePath(t,"models/{modelId}/export/{format}")),this.setEnpointIfNotExist("GetQueryFile",o.combinePath(t,"models/{modelId}/getqueryfile/{format}")),this.setEnpointIfNotExist("UploadQueryFile",o.combinePath(t,"models/{modelId}/uploadqueryfile"))},t.prototype.initStart=function(){this.servicesInitialized=!0},t.prototype.init=function(t){var e=this;(this.servicesInitialized||this.initStart(),void 0!==(t=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&&a.k.setCurrentLocale(t.locale),t.localeSettings&&a.k.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)for(var r=0,n=t.serverExporters;r<n.length;r++){var o=n[r],i="csv"==o||"excel-html"==o?"":"arraybuffer";this.registerServerExporter(o,i)}var s=this.getQuery();t.defaultQueryId&&s.setId(t.defaultQueryId),this.widgets.forEach((function(r){var n={};t.widgets&&t.widgets[r.getWidgetType()]&&(n=t.widgets[r.getWidgetType()]),r.init(e,n)})),this.loadModelOnStart?this.loadDefaultModel():this.fireEvent("ready")},t.prototype.useEndpoint=function(t){return this.baseEndpoint=t,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=k.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===$.Error&&this.throwError(t),this.widgets.forEach((function(t){t.belongsToGroup(e)&&t.onProcessEnd()}))},t.prototype.throwError=function(t){t.result=$.Error,this.eventEmitter.fire("error",t)},t.prototype.loadDefaultModel=function(){var t=this;this.loadModel({modelId:this.defaultModelId,silent:!0,success:function(){t.refreshWidgets(k.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(k.Query),t.fireEvent("ready")}}):(t.refreshWidgets(k.Query),t.fireEvent("ready"))}})},t.prototype.clearQuery=function(){var t=this.getQuery();t.clear(),t.fireChangedEvent({part:C.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){a.k.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:q.GetValueList,text:"Loading values"},k.Result),this.eqServices.getValueListResolver().loadValueList(t).then((function(r){e.endProcess({result:$.Success,action:q.GetValueList,text:"Values loaded"},k.Result),t.success&&t.success(r)})).catch((function(r){var n="Can't load the value list for editor "+(t&&t.params?t.params.editorId:"undefined")+".\n "+r.message;e.endProcess({result:$.Error,action:q.GetValueList,text:n,sourceError:r},k.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",n=t.silent||!1;return this.startProcess({action:q.LoadModel,text:"Loading model: "+r},k.Model),this.eqServices.getModelLoader().startModelLoading(t).then((function(o){return o?(e.loadModelFromData(o),e.dataModel.isEmpty()&&console.warn("Empty model has been loaded. Model ID: "+e.dataModel.getId())):console.warn("Model has not been changed."),e.fireEvent("loadModel"),e.endProcess({result:$.Success,action:q.LoadModel,text:"Model loaded: "+r},k.Model),n||(e.clearQuery(),e.clearResult(),e.refreshWidgets()),t.success&&t.success(e.getModel()),e.getModel()})).catch((function(n){var o="Can't load model "+r+".\n "+n.message;return e.endProcess({result:$.Error,action:q.LoadModel,text:o,sourceError:n},k.Model),t.error&&t.error(o,"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,n=t.silent||!1;e.beforeLoadQuery&&e.beforeLoadQuery(e,t),e.startProcess({action:q.LoadQuery,text:"Query loading: "+r},k.Query),e.eqServices.getQueryStorage().loadQuery(t).then((function(o){o&&e.query.loadFromData(o,{validate:!1}),e.fireEvent("loadQuery"),e.endProcess({result:$.Success,action:q.LoadQuery,text:"Query loaded: "+r},k.Query),e.query.resetModified(),n||(e.query.fireChangedEvent({part:C.Properties,wasModified:e.query.isModified()}),e.refreshWidgets()),t.success&&t.success(e.query)})).catch((function(r){var n=e.getQuery();r.message="Can't load query ["+n.getId()+"]\n"+(r.message||""),t.error&&t.error(r.message,q.LoadQuery),e.endProcess({result:$.Error,action:q.LoadQuery,text:r.message,sourceError:r},k.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 "+t.message;e.throwError({action:q.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 n="Can't load the list of available queries.\n "+r.message;t.error?t.error(n,"LoadQueryList"):e.throwError({action:q.LoadQueryList,text:n,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 n=t.silent||!1,o=!0;void 0!==t.useStorage&&(o=t.useStorage);var i=function(){var t=e.getQuery();t.isNewbie=!0,n||t.fireChangedEvent({part:C.All,wasModified:t.isModified()})};o?(this.startProcess({action:q.NewQuery,text:"New query creation..."},k.Query),this.eqServices.getQueryStorage().newQuery(t).then((function(r){r&&e.query.loadFromData(r),e.endProcess({result:$.Success,action:q.NewQuery,text:"A new query has been created"},k.Query),i(),t.success&&t.success()})).catch((function(r){var n="Can't create a new query.\n"+r.message;e.endProcess({result:$.Error,action:q.NewQuery,text:n,sourceError:r},k.Query),t.error&&t.error(n,"NewQuery")}))):i();return this.query},t.prototype.saveQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:q.SaveQuery,text:"Query saving: "+r.getId()},k.Query),this.eqServices.getQueryStorage().saveQuery(t).then((function(n){e.endProcess({action:q.SaveQuery,result:$.Success,text:"Query saved: "+r.getId()},k.Query),n&&r.loadFromData(n),r.resetModified(),r.isNewbie=!1,t.success&&t.success()})).catch((function(n){var o="Can't save query "+r.getId()+".\n "+n.message;e.endProcess({action:q.SaveQuery,result:$.Error,text:o,sourceError:n},k.Query),t.error&&t.error(o,q.SaveQuery)}))},t.prototype.removeQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:q.RemoveQuery,text:"Query deleting: "+r.getId()},k.Query),this.eqServices.getQueryStorage().removeQuery(t).then((function(){r.reset(),e.endProcess({action:q.RemoveQuery,result:$.Success,text:"Query deleted: "+r.getId()},k.Query),t.success&&t.success()})).catch((function(n){var o="Can't remove query "+r.getId()+".\n "+n.message;e.endProcess({action:q.RemoveQuery,result:$.Error,text:o,sourceError:n},k.Query),t.error&&t.error(o,"RemoveQuery")}))},t.prototype.syncQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.beforeSyncQuery&&this.beforeSyncQuery(this,t),this.startProcess({action:q.SyncQuery,text:"Query syncing: "+r.getId()},k.Query),this.eqServices.getQuerySynchronizer().syncQuery(t).then((function(n){if(e.resultStatement=n&&n.statement?n.statement:"",e.fireEvent("syncQuery"),e.refreshWidgets(k.Statement),e.endProcess({result:$.Success,action:q.SyncQuery,text:"Query synced: "+r.getId()},k.Query),n){if(n.querySaved){var o=n.query;o&&(r.setId(o.id),r.setName(o.name),r.setDescription(o.desc),r.extraData=o.extraData),r.resetModified(),e.refreshWidgets(k.QueryStatus)}t.success&&t.success(n)}})).catch((function(n){var o="Can't synchronize query "+r.getId()+".\n "+n.message;e.endProcess({result:$.Error,action:q.SyncQuery,text:o,sourceError:n},k.Query),t.error&&t.error(o,"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(tt(tt({},t),{success:function(r){if(r.statement&&(e.resultStatement=r.statement,e.refreshWidgets(k.Statement)),e.getServices().getAggregatesCalculator().reset(),e.resultContent=r,r.resultSet){e.resultTable.clear(),e.resultTable.id=e.query.getId();for(var n=r.resultSet,o=0,i=n.cols;o<i.length;o++){var s=i[o];e.resultTable.columns.add(s)}r.meta&&void 0!==r.meta.totalRecords&&e.resultTable.setTotal(r.meta.totalRecords);var a=n.rows.length;e.resultTable.elasticChunks&&a===t.chunk.limit&&n.rows.splice(n.rows.length-1,1);for(var u=0,l=n.rows;u<l.length;u++){var d=l[u];e.resultTable.addRow(d)}e.resultTable.elasticChunks&&(e.resultTable.total=a<t.chunk.limit?n.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:q.GetQueryFile,text:"Getting query file: "+r.getId()},k.Query),this.getServices().getQueryFileLoader().getQueryFile(t).then((function(){e.endProcess({result:$.Success,action:q.GetQueryFile,text:"Getting query file: "+r.getId()},k.Result),t.success&&t.success()})).catch((function(n){var o="Can't get file for query "+r.getId()+".\n "+n.message;e.endProcess({result:$.Error,action:q.GetQueryFile,text:o,sourceError:n},k.Query),t.error&&t.error(o,"GetQueryFile")}))},t.prototype.uploadQueryFile=function(t){var e=this,r=this.getQuery();this.startProcess({action:q.UploadQueryFile,text:"Uploading query file: "+r.getId()},k.Query),this.getServices().getQueryFileLoader().uploadQueryFile(t).then((function(n){r.loadFromData(n),e.fireEvent("loadQuery"),e.refreshWidgets(),e.endProcess({result:$.Success,action:q.UploadQueryFile,text:"Uploading query file: "+r.getId()},k.Result),t.success&&t.success()})).catch((function(n){var o="Can't upload a file for query "+r.getId()+".\n "+n.message;e.endProcess({result:$.Error,action:q.UploadQueryFile,text:o,sourceError:n},k.Query),t.error&&t.error(o,"UploadQueryFile")}))},t.prototype.fetchDataChunk=function(t){var e=this,r=this.getQuery().getId(),n=t||{};this.useStoredQueryOnFetch&&(n.queryId=this.query.getId()),this.beforeFetchData&&this.beforeFetchData(this,n),this.startProcess({action:q.FetchData,text:"Fetching data for the query: "+r},k.Result),this.eqServices.getDataFetcher().fetchData(n).then((function(t){t.statement&&(e.resultStatement=t.statement),e.resultContent=t,n.success&&n.success(t),e.fireEvent("fetchData"),e.endProcess({result:$.Success,action:q.FetchData,text:"Data fetching is finished for the query: "+r},k.Result)})).catch((function(t){var o="Data fetching error for the query "+r+". \n"+t.message;e.endProcess({result:$.Error,action:q.FetchData,text:o,sourceError:t},k.Result),n.error&&n.error(o,q.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 "+e.level+" query. \n"+e.message;t.throwError({action:q.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:q.FetchData,text:"DrillDown executing: "+r},k.Result),this.eqServices.getDataFetcher().fetchData(t).then((function(n){e.endProcess({result:$.Success,action:q.FetchData,text:"DrillDown execution error: "+r},k.Result),t.success&&t.success(n)})).catch((function(n){var o="Drill-down data fetching error for query "+r+". \n"+n.message;e.endProcess({result:$.Error,action:q.FetchData,text:o},k.Result),t.error?t.error(o,"DrillDown"):e.throwError({action:q.FetchData,text:o})}))},t.prototype.exportResult=function(t){var e=this;t=t||{},this.beforeExportResult&&this.beforeExportResult(this,t);var r=t.format;if(r){var n=this.getExporter(r);if(n){var o=this.getQuery().getId();this.useStoredQueryOnFetch&&(t.queryId=o),this.startProcess({action:q.ExportResult,text:"Exporting result for query: "+o},k.Result);var i=a.k.getLocaleSettings();t.settings=i;var s=this.query.getAggregationSettings();s.hasAggregates()&&(s.hasGrandTotals()||s.hasGroups())&&(t.aggregates=s.saveToData()),n.export(t).then((function(r){e.fireEvent("exportResult"),e.endProcess({result:$.Success,action:q.ExportResult,text:"The result set for query ["+o+"] has been successfully exported"},k.Result),t.success&&t.success()})).catch((function(r){var n="Error on exporting data for query "+o+". \n"+r.message;e.endProcess({result:$.Error,action:q.ExportResult,text:n,sourceError:r},k.Result),t.error&&t.error(n,"ExportResult")}))}}},t}(),rt=function(){function t(t){this.slot=t,this._id=a.l.generateId(this.getWidgetType())}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,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}(),nt=new(function(){function t(t,e,r){this.major=t,this.minor=e,this.update=r}return t.prototype.toString=function(){return this.major+"."+this.minor+"."+this.update},t}())(6,2,0);a.k.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:{},AggreateFunctions:{}})}])}));
|
|
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()}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){"use strict";var n,o;r.d(e,"b",(function(){return n})),r.d(e,"d",(function(){return s})),r.d(e,"f",(function(){return m})),r.d(e,"g",(function(){return E})),r.d(e,"h",(function(){return v})),r.d(e,"i",(function(){return b})),r.d(e,"j",(function(){return x})),r.d(e,"a",(function(){return D})),r.d(e,"c",(function(){return A})),r.d(e,"e",(function(){return F})),r.d(e,"k",(function(){return a})),r.d(e,"l",(function(){return 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"}(n||(n={})),function(t){t[t.Data=0]="Data",t[t.Virtual=1]="Virtual",t[t.Lookup=2]="Lookup"}(o||(o={}));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 n=r[e].split(": "),o=n.shift(),i=n.join(": ");t[o]=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 d(t,e){for(var r="",n=0;n<e;n++)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"},o={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":o},s=[];function a(t){for(var e=0,r=s;e<r.length;e++){(0,r[e])(t)}}function l(){return e.localeId}function d(t){var r=i[t];r?u.assignDeep(e,r):(e.englishName=t,e.displayName=t,e.texts=u.assignDeep({},o.texts)),e.localeId=t}function c(){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 n=e;t&&(r.localeId||(r.localeId=t),(n=i[t])||(n=u.assignDeep({},o),i[t]=n)),u.assignDeep(n,r)}function f(){var t,r,n,o,i,s,a="object"==typeof navigator?navigator.language:void 0;t=a,r=new Date(2020,5,7,19,34,56,88),n=r.toLocaleDateString(t,{year:"numeric",month:"numeric",day:"numeric"}),o=r.toLocaleTimeString(t,{hour:"numeric",minute:"numeric",second:"numeric"}),i=n.replace("07","dd").replace("7","d").replace("06","MM").replace("6","M").replace("2020","yyyy").replace("20","yy"),s=o.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 y(t){var e,r=c();switch(t){case n.Date:e=r.shortDateFormat;break;case n.Time:e=r.shortTimeFormat;break;default:e=r.shortDateFormat+" "+r.shortTimeFormat}return e}function g(t){var e,r=c();switch(t){case n.Date:e=r.longDateFormat;break;case n.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"),d(t)},t.setCurrentLocale=d,t.getText=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=e.texts,o="";if(t&&t.length)for(var i=t.length,s=0;s<i&&"object"==typeof(o=n[t[s]]);s++)n=o;return o},t.getLocaleSettings=c,t.getOneLocaleSetting=function(t){return e.settings[t]},t.getShortMonthName=function(t){var e=c();if(t>0&&t<13)return e.shortMonthNames[t-1];throw"Wrong month number: "+t},t.getLongMonthName=function(t){var e=c();if(t>0&&t<13)return e.longMonthNames[t-1];throw"Wrong month number: "+t},t.getShortWeekDayName=function(t){var e=c();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=c();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 n=i[r];n.texts=u.assignDeep({},t,n.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({},o),f())},t.dateTimeToStr=function(t,e,r){return r?"d"==r?r=y(n.Date):"D"==r?r=g(n.Date):"f"==r?r=y(n.DateTime):"F"==r&&(r=g(n.DateTime)):r=y(e),u.dateTimeToStr(t,r)},t.numberToStr=function(e,r){if(r&&r.length>0){var n=r.charAt(0).toUpperCase();if("S"===n)return function(e,r){if(!m[r]){var n=r.split("|").filter((function(t){return t.length>0})).map((function(t){return t.split("=")}));if(m[r]={},n.length>0)if(n[0].length>1)for(var o=0,i=n;o<i.length;o++){var s=i[o];m[r][Number.parseInt(s[1])]=s[0]}else n.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(n)>=0){var o=l();return e.toLocaleString(o,function(t){var e=c(),r=t[0].toUpperCase(),n=t.length>1?Number.parseInt(t.slice(1)):"D"==r?1:2;switch(r){case"D":return{style:"decimal",useGrouping:!1,minimumIntegerDigits:n};case"C":return{style:"currency",currency:e.currency,minimumFractionDigits:n};default:return{style:"decimal",minimumFractionDigits:n}}}(r))}return function(t,e){for(var r=t.toString(),n="",o=r.length-1,i=e.length-1;i>=0;i--){var s=e.charAt(i);"#"===s||"0"===s?o>=0?(n+=r.charAt(o),o--):"0"===s&&(n+=0):n+=s}return n.split("").reverse().join("")}(Math.trunc(e),r)}var i=c();return u.numberToStr(e,i.decimalSeparator)},t.booleanToStr=function(e,r){if(r&&r.length>0&&"S"===r.charAt(0).toUpperCase()){var n=r.slice(1).split("|");if(n.length>1){var o=n[e?1:0];return t.getText(o)||o}}return""+e};var m={}}(a||(a={})),function(t){t.getAllDataTypes=function(){return Object.values(n).filter((function(t){return"number"==typeof t}))},t.getDateDataTypes=function(){return[n.Time,n.Date,n.DateTime]},t.getStringDataTypes=function(){return[n.String,n.Memo,n.FixedChar]};var e=[n.Byte,n.Word,n.Int32,n.Int64,n.Float,n.Currency,n.Autoinc];t.getNumericDataTypes=function(){return e};var r=[n.Byte,n.Word,n.Int32,n.Int64,n.Autoinc];function o(t,e,r){e||(e={});for(var n=0,s=r;n<s.length;n++){var a=s[n];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]),o(t,e[u],[l])):e[u]=l}}return e}function i(t){for(var e=[],r=0,n=t;r<n.length;r++){var o=n[r];e.push(o)}return e}t.assign=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0;n<e.length;n++){var o=e[n];if(o)for(var i in o)o.hasOwnProperty(i)&&(t[i]=o[i])}return t},t.assignDeep=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return o(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,n=e.length,o=0;o<r&&o<n;o++)e[o]=t[o]},t.createArrayFrom=i,t.findItemById=function(t,e){for(var r=t.length,n=0;n<r;n++)if(t[n].id===e)return t[n];return null},t.findItemIndexById=function(t,e){for(var r=t.length,n=0;n<r;n++)if(t[n].id===e)return n;return-1},t.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var r=t.length,n=0;n<r;n++)if(e==t[n])return n;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 n=t.splice(e,1)[0];t.splice(r,0,n)},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,n){void 0===r&&(r=0);for(var o=t.length>>>0,i=r>>0,s=i<0?Math.max(o+i,0):Math.min(i,o),a=void 0===n?o:n>>0,u=a<0?Math.max(o+a,0):Math.min(a,o);s<u;)t[s]=e,s++;return t},t.shiftToFitWindow=function(t,e){var r=document.getElementsByTagName("body")[0],n=window.innerWidth||document.documentElement.clientWidth||r.clientWidth,o=t+e,i=0;return o>n&&t+(i=n-o-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==n.Unknown||e==n.Unknown||t==e||t==n.Date&&e==n.DateTime||t==n.DateTime&&e==n.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 n=r/e,o="";o+=t[0];for(var i=n,s=void 0,a=1;a<r;a++)s=t[a],a+1>i&&(o+=s,i+=n);return o}return t}function l(t,e,r){return t.substr(0,e)+r+t.substr(e+r.length)}function c(t,e){return Math.floor(Math.random()*(e-t))+t}function h(t){var e=parseInt(t);if(isNaN(e))throw'"'+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("-"),n=1,o=e;r.length<e&&(n=e/r.length,o=r.length);for(var i="",s=0;s<o;s++)i+=u(r[s],n);return i}(t,4):t;e&&e.length>0&&(e+="-");var r=d("",2),n=s.length-1;return r=l(r,0,s[c(0,n)]),e+(r=l(r,1,s[c(0,n)]))+function(t){var e=36,r=14,n=d("",r),o=t;do{n=l(n,r--,s[o%e]),o=Math.floor(o/=e)}while(o>0);return i=n.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,"-"),n=e.replace(/[^a-zA-Z0-9_]/g,"-").split("-"),o=r.split("-"),i=n.indexOf("MM"),s=n.indexOf("dd"),a=n.indexOf("yyyy"),u=n.indexOf("HH"),l=n.indexOf("mm"),d=n.indexOf("ss"),c=new Date;try{var p=a>-1&&a<o.length?h(o[a]):c.getFullYear(),f=i>-1&&i<o.length?h(o[i])-1:c.getMonth()-1;if(f>11)throw"";var y=s>-1&&s<o.length?h(o[s]):c.getDate();if(y>function(t,e){return new Date(e,t+1,0).getDate()}(f,p))throw"";var g=u>-1&&u<o.length?h(o[u]):0;if(g>23)throw"";var m=l>-1&&l<o.length?h(o[l]):0;if(m>59)throw"";var v=d>-1&&d<o.length?h(o[d]):0;if(v>59)throw"";return new Date(p,f,y,g,m,v)}catch(e){throw 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 n=e.length>1?h(e[1]):0;if(n>59)throw"";var o=e.length>1?h(e[1]):0;if(o>59)throw"";return new Date(0,0,0,r,n,o)}catch(e){throw t+" is not a valid time."}};var p=/\[([^\]]+)]|y{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(),n=t.getMonth()+1,o=t.getDate(),i=t.getHours(),s=t.getMinutes(),u=t.getSeconds(),l=i%12||12,d=i>11,c={yyyy:r.toString(),MMMM:a.getLongMonthName(n),MMM:a.getShortMonthName(n),MM:n<10?"0"+n:n.toString(),M:n.toString(),dd:o<10?"0"+o:o.toString(),d:o.toString(),HH:i<10?"0"+i:i.toString(),H:i.toString(),hh:l<10?"0"+l:l.toString(),h:l.toString(),tt:d?"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||c[t]}))},t.numberToStr=function(t,e){return e=e||a.getLocaleSettings().decimalSeparator,t.toString().replace(".",e)}}(u||(u={}));var c,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=(c=function(t,e){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},c(t,e)},function(t,e){function r(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),y=function(){return y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y.apply(this,arguments)},g=function(t){function e(e,r){var n=t.call(this,r)||this;return n.status=e,n}return f(e,t),e}(Error),m=function(){function t(){this.defaultHeaders={},this.customPayload=void 0}return 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,n,o){var i=(o=o||{}).dataType||"json",s=o.contentType||"form-data"!==i?"application/json":null;n&&"form-data"!=i&&this.customPayload&&(n.data=u.assignDeep(n.data||{},this.customPayload));var a=new("onload"in new XMLHttpRequest?XMLHttpRequest:window.XDomainRequest),d={method:e,url:r,headers:y(y({},this.defaultHeaders),o.headers||{}),queryParams:o.queryParams||{},data:n};s&&(d.headers["Content-Type"]=s);var c=new l(a,d);this.beforeEachRequest&&(console.warn("HttpClient: 'beforeEachRequest' is deprecated and will be removed in future updates.\n Use 'onRequest' instead"),this.beforeEachRequest(c)),this.onRequest&&this.onRequest(c);var h=c.data&&"string"!=typeof c.data&&"json"==i?JSON.stringify(c.data):c.data;return c.open(),new p(c,new Promise((function(e,n){o.responseType&&(a.responseType=o.responseType),a.onerror=function(t){n(new g(a.status,a.responseText))},a.onreadystatechange=function(){if(4==a.readyState){var o=a.getResponseHeader("Content-Type")||"",i=a.status;if(0===i)n(new g(i,"Network error or the request was aborted"));else if(i>=200&&i<400){var s="arraybuffer"===a.responseType||"blob"===a.responseType?a.response:0==o.indexOf("application/json")?JSON.parse(a.responseText):a.responseText;e(s)}else{("arraybuffer"===a.responseType||"blob"===a.responseType?t.decodeArrayBuffer(a.response):Promise.resolve(a.responseText)).then((function(t){var e=0==o.indexOf("application/json")?JSON.parse(t):t,s=e.message||(404==i?"No such endpoint: "+r:e);n(new g(i,s))}))}}},a.send(h)})))},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 n=t.createEntity(this);n.loadFromData(t,e.ents[r]),this.subEntities.push(n)}if(this.attributes=new Array,e.attrs)for(r=0;r<e.attrs.length;r++){var o=t.createEntityAttr(this);o.loadFromData(t,e.attrs[r]),this.attributes.push(o)}}},t.prototype.scan=function(t,e){var r={stop:!1},n=function(o){if(e&&e(o,r),o.attributes)for(var i=o.attributes.length,s=0;s<i&&!r.stop;s++){var a=o.attributes[s];if(t&&t(a,r),r.stop)return}if(o.subEntities){var u=o.subEntities.length;for(s=0;s<u&&!r.stop;s++)n(o.subEntities[s])}};n(this)},t.prototype.getFirstPrimaryAttr=function(){return this.getPrimaryAttrs()[0]},t.prototype.getPrimaryAttrs=function(){return this.attributes.filter((function(t){return t.isPrimaryKey}))},t}(),b=function(){function t(t){this.id="",this.caption="{Unrecognized attribute}",this.dataType=n.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=o.Data}return t.prototype.loadFromData=function(t,e){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,this.defaultValue=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}(),x=function(){function t(){this.id="",this.tag=s.Unknown,this.resType=n.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,n=this.values;r<n.length;r++){var o=n[r];t.indexOf(o.id)>=0&&(e+=o.text+",")}else for(var i=0,s=this.values;i<s.length;i++){(o=s[i]).id===t&&(e+=o.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 b(t)},t.prototype.createValueEditor=function(){return new x},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 o in t.displayFormats){var i=n[o],s=t.displayFormats[o]||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 n=r[e];if(n.id===t)return n}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,n;if(t.attributes){var o=t.attributes.length;for(r=0;r<o;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(n=this.getEntityAttrById(t.subEntities[r],e))return n}return null},t.prototype.listByEntityWithFilter=function(t,e){var r,n=new Array,o=null;if(t.subEntities)for(var i=t.subEntities.length,s=0;s<i;s++){if(o=t.subEntities[s],!e||e(o,null))(r=a.getText("Entities",o.name))||(r=o.caption),(h=u.assign(this.createEntity(),{id:o.name,text:r,items:[],isEntity:!0})).items=this.listByEntityWithFilter(o,e),h.items.length>0&&n.push(h)}var l=null;if(t.attributes)for(var d=t.attributes.length,c=0;c<d;c++)if(l=t.attributes[c],!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});n.push(h)}return n},t.prototype.listByEntity=function(t,e,r){e=e||{};var n,o=[],i=[],s=null;if(t.subEntities)for(var l=t.subEntities.length,d=0;d<l;d++)if(s=t.subEntities[d],!r||r(s,null)){n=a.getText("Entities",s.name)||s.caption;var c=u.assign(this.createEntity(),{id:s.name,text:n,items:[],isEntity:!0,description:s.description}),h=u.assign({},e);h.includeRootData=!1,c.items=this.listByEntity(s,h,r),c.items.length>0&&o.push(c)}var p=null;if(t.attributes)for(var f=t.attributes.length,y=0;y<f;y++)p=t.attributes[y],r&&!r(t,p)||(n=a.getText("Attributes",p.id)||p.caption,i.push(u.assign(this.createEntityAttr(t),{id:p.id,text:n,dataType:p.dataType,lookupAttr:p.lookupAttr,description:p.description})));var g,m=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(o.sort(m),i.sort(m)),g=e.attrPlacement&&0!=e.attrPlacement?i.concat(o):o.concat(i),2==e.attrPlacement&&g.sort(m),e.includeRootData?((n=a.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:g}):g},t.prototype.clear=function(){this.rootEntity=this.createEntity(),this.editors=[],this.version=""},t.prototype.addDefaultValueEditors=function(){this.addOrUpdateValueEditor("_DTE",s.Edit,n.String).defValue="",this.addOrUpdateValueEditor("_DPDE",s.DateTime,n.DateTime),this.addOrUpdateValueEditor("_DPTE",s.DateTime,n.DateTime)},t.prototype.addOrUpdateValueEditor=function(t,e,r){var n=u.findItemById(this.editors,t);return n||((n=this.createValueEditor()).id=t,this.editors.push(n)),n.tag=e,n.resType=r,n},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,n){if(!t)return"";r=r||" ";var o="";if(t.caption&&!n){var i=a.getText("Entities",t.caption);o=i||t.caption}if(t.attributes)for(var s=t.attributes.length,u=0;u<s;u++)if(t.attributes[u].id==e)return o;if(t.subEntities){var l=t.subEntities.length;for(u=0;u<l;u++){var d=t.subEntities[u],c=this.getEntityPathByAttr(d,e,r,!1);if(""!==c)return""!==o&&(c=o+r+c),c}}return""},t.prototype.getAttributeText=function(t,e){var r=a.getText("Attributes",t.id);if(r||(r=t.caption),!e)return r;var n=this.getFullEntityPathByAttr(t.id," ");return(n?e.replace(new RegExp("{attr}","g"),r).replace(new RegExp("{entity}","g"),n):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,n){t(r)&&(n.stop=!0,e=r)}),null),e},t}(),C=function(){return C=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},C.apply(this,arguments)},D=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:!0,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 n=0,o=this.aggregates;n<o.length;n++){var i=o[n];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,n={};if(t)for(var o=0,i=t.columns;o<i.length;o++){var s=i[o],a=e.getValue(s);r&&"string"==typeof a&&(a=a.toLowerCase()),n[s]=a}return n},t.prototype.strictCompare=function(t,e){return t===e},t.prototype.caseInsensitiveCompare=function(t,e){return("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 T,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,n.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},w=function(){function t(){this.items=[],this.mapper={},this._dateColumnIdx=[]}return Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!0,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,[n.Date,n.DateTime,n.Time].indexOf(e.type)>=0&&this._dateColumnIdx.push(r),r},t.prototype.updateDateColumnIdx=function(){this._dateColumnIdx=this.getItems().filter((function(t){return[n.Date,n.DateTime,n.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 '"+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 '"+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 w,this.onUpdate=t.onUpdate,t.columns)for(var e=0,r=t.columns;e<r.length;e++){var n=r[e];this._columns.add(n)}if(t.rows)for(var o=0,i=t.rows;o<i.length;o++){var s=i[o],a=this.createRow(s);this.addRow(a)}this.needTotal=!this._elasticChunks}return Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},enumerable:!0,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:!0,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:!0,configurable:!0}),t.prototype.getRows=function(t){var e=this,r=0,n=this._chunkSize;t&&("page"in t?(r=t.pageSize*(t.page-1),n=t.pageSize):(r=t.offset,n=t.limit));var o=r+n;if(!this.needTotal&&!this.elasticChunks){if(r>=this.total)return Promise.resolve([]);o>this.total&&(o=this.total)}if(this.isInMemory&&o>this.cachedRows.length&&(o=this.cachedRows.length),o<=this.cachedRows.length)return Promise.resolve(this.cachedRows.slice(r,o));if(!this.loader)throw"Loader is not defined. Can't get the rows from "+r+" to "+o;var i=this.needTotal;this.needTotal&&(this.needTotal=!1);var s=this.cachedRows.length,a=o-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()),o>e.cachedRows.length&&(o=e.cachedRows.length),e.elasticChunks)&&(t.table.getCachedCount()<a&&(e.total=e.cachedRows.length));return e.fireUpdated(),e.cachedRows.slice(r,o)}))},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(),n=new Array(this._columns.count),o=t instanceof S?function(e){return t.getValue(e)}:function(e){return t[e]};return t&&this.columns.getItems().forEach((function(t){var i=o(t.id),s=e.columns.getIndex(t.id);n[s]=r.indexOf(s)>=0?e.mapDate(i,t.type):i})),new S(this._columns,n)},t.prototype.mapDate=function(t,e){if(t){var r=new Date(t);return isNaN(r.getTime())&&e==n.Time&&(r=u.strToTime(t)),r}return null},t.prototype.addRow=function(t){var e;if(Array.isArray(t)){var r=t,n=this._columns.getDateColumnIndexes();if(n.length>0)for(var o=0,i=n;o<i.length;o++){var s=i[o];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}(),O=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}(),F=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),n={id:O.newGuid(),callback:e};return r?r.eventCallbacks.push(n):(r={type:t,eventCallbacks:new Array(n)},this.events.push(r)),n.id},t.prototype.unsubscribe=function(t,e){var r=this.getEventRecByType(t);if(r){var n=-1;for(n=0;n<r.eventCallbacks.length&&r.eventCallbacks[n].id!==e;n++);n>=0&&r.eventCallbacks.splice(n,1)}},t.prototype.fire=function(t,e,r,n){if(void 0===r&&(r=0),void 0===n&&(n=!1),!this.silentMode||n){var o=this.getEventRecByType(t);if(o){var i={type:t,source:this.source,data:e},s=function(){for(var t=0,e=o.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 n=r[e];if(n.type==t)return n}return null},t}();!function(t){t.renderLiquidTemplate=function(t,e){var r=t;if(e)for(var n in e){var o=new RegExp("{{"+n+"}}","g");r=r.replace(o,e[n])}return r}}(T||(T={})),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)})},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return GoogleDataConverter}));var _easydata_core__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),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__.b.Date,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.DateTime,_easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Time].includes(colType)?eval("new "+value):value},GoogleDataConverter.prototype.getValue=function(t,e){var r=t<this.tableObj.rows.length?this.tableObj.rows[t]:null;if(r){var n=e<this.tableObj.cols.length?r.c[e]:null;if(n)return this.convertValue(n.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 n=this.getNumberOfRows();for(r=0;r<n;r++)t.addRow(this.getRow(r))},GoogleDataConverter.prototype.googleDataTypeToDataType=function(t){switch(t){case"string":default:return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.String;case"number":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Float;case"boolean":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Bool;case"date":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Date;case"datetime":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.DateTime;case"timeofday":return _easydata_core__WEBPACK_IMPORTED_MODULE_0__.b.Time}},GoogleDataConverter}()},function(t,e,r){"use strict";r.r(e),r.d(e,"equtils",(function(){return o})),r.d(e,"eqconsts",(function(){return s})),r.d(e,"EqServiceProvider",(function(){return z})),r.d(e,"Tree",(function(){return I})),r.d(e,"EasyQueryDataLoader",(function(){return K})),r.d(e,"GoogleDataConverter",(function(){return Y.a})),r.d(e,"EqAggregatesContainer",(function(){return H})),r.d(e,"DefaultAggregatesCalculator",(function(){return J})),r.d(e,"DataKind",(function(){return d})),r.d(e,"LinkType",(function(){return n})),r.d(e,"CondTag",(function(){return O})),r.d(e,"ConditionPart",(function(){return F})),r.d(e,"ExprTag",(function(){return f})),r.d(e,"EqEditorTag",(function(){return E})),r.d(e,"WidgetGroup",(function(){return k})),r.d(e,"AggrFunction",(function(){return c})),r.d(e,"DataModel",(function(){return S})),r.d(e,"Entity",(function(){return v})),r.d(e,"EntityAttr",(function(){return b})),r.d(e,"Operator",(function(){return y})),r.d(e,"Operand",(function(){return g})),r.d(e,"EqValueEditor",(function(){return p})),r.d(e,"EqAction",(function(){return q})),r.d(e,"EqModelLoader",(function(){return N})),r.d(e,"InMemoryModelStorage",(function(){return X})),r.d(e,"BrowserQueryStorage",(function(){return Q})),r.d(e,"EqContext",(function(){return et})),r.d(e,"Widget",(function(){return rt})),r.d(e,"EqActionResult",(function(){return $})),r.d(e,"SortDirection",(function(){return T})),r.d(e,"QueryColumn",(function(){return M})),r.d(e,"Condition",(function(){return L})),r.d(e,"Expression",(function(){return A})),r.d(e,"InvalidQueryError",(function(){return _})),r.d(e,"Query",(function(){return P})),r.d(e,"QueryChangePart",(function(){return C})),r.d(e,"QueryChangeAction",(function(){return D})),r.d(e,"EqServerExporter",(function(){return Z})),r.d(e,"EqServerModelLoader",(function(){return j})),r.d(e,"EqServerDataFetcher",(function(){return G})),r.d(e,"EqServerQuerySynchronizer",(function(){return U})),r.d(e,"EqServerValueListResolver",(function(){return V})),r.d(e,"EqQueryFileLoader",(function(){return W})),r.d(e,"FormatParser",(function(){return u})),r.d(e,"versionInfo",(function(){return nt})),r.d(e,"i18n",(function(){return a.k}));var n,o,i,s,a=r(0),u=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"}(n||(n={})),(i=o||(o={})).combinePath=function(t,e){var r=t;return null!=r&&r.length>0?("/"!=r.charAt(r.length-1)&&(r+="/"),r+=e):r=e,r},i.strToLinkType=function(t){return"All"==t?n.All:"NotAll"==t?n.NotAll:"Any"==t?n.Any:n.None},i.linkTypeToStr=function(t){return t===n.All?"All":t===n.NotAll?"NotAll":t==n.Any?"Any":"None"},i.parseOperatorFormat=function(t){var e=a.k.getText("Operators",t.id,"format");return e||(e=a.k.getText("Operators",t.id,"displayFormat")),e||(e=t.displayFormat),new u(e).parse()},i.convertValue=function(t,e,r){switch(r){case a.b.String:return t;case a.b.Autoinc,a.b.Byte,a.b.Int32,a.b.Int64,a.b.Word:var n=parseInt(t);return isNaN(n)?"":n.toString();case a.b.Currency,a.b.Float:var o=parseFloat(t);return isNaN(o)?"":o.toString();default:return""}},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"}]}(s||(s={}));var l,d,c=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?[a.b.Autoinc,a.b.Byte,a.b.Currency,a.b.Float,a.b.Int32,a.b.Int64,a.b.Word]:"MIN"===this.id||"MAX"===this.id?[a.b.Autoinc,a.b.BCD,a.b.Byte,a.b.Currency,a.b.Date,a.b.DateTime,a.b.Time,a.b.Float,a.b.Int32,a.b.Int64,a.b.Word]:a.l.getAllDataTypes()},t}(),h=(l=function(t,e){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},l(t,e)},function(t,e){function r(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),p=function(t){function e(){return t.call(this)||this}return h(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}(a.j);!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"}(d||(d={}));var f,y=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 g,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 p),e.operands))for(var r=0;r<e.operands.length;r++){var n=new g;n.loadFromData(t,e.operands[r]),e.editor&&(n.editor=t.getEditorById(e.editor)||new p),this.operands.push(n)}},t}(),g=function(){function t(){this.kind=d.Scalar,this.dataType=a.b.Unknown,this.editor=new p,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 p)},t.prototype.copyFrom=function(t){a.l.assign(this,t)},t}(),m=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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),v=function(t){function e(e){var r=t.call(this,e)||this;return r.useInConditions=!1,r.useInResult=!1,r.useInSorting=!1,r}return m(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}(a.h),b=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 m(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}(a.i),x=function(){return x=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},x.apply(this,arguments)},E=x(x({},a.d),{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"}(f||(f={}));var C,D,T,I=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 n=r[e].findNode(t);if(n)return n}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}(),w=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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),S=function(t){function e(){var e=t.call(this)||this;return e.mainEntity=null,e.nullAttribute=new b(null),e.nullOperator=new y,e.operators=new Array,e.rootEntity=new v,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 w(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 n=new y;n.loadFromData(this,e.operators[r]),this.operators.push(n)}if(this.rootEntity.loadFromData(this,e.entroot),this.aggrFunctions=new Array,e.aggrfuncs)for(r=0;r<e.aggrfuncs.length;r++){var o=new c;o.loadFromData(e.aggrfuncs[r]),this.aggrFunctions.push(o)}},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 v(t)},e.prototype.createEntityAttr=function(t){return new b(t)},e.prototype.createValueEditor=function(){return new p},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,o=null;if(t.subEntities)for(var i=t.subEntities.length,s=0;s<i;s++){if(o=t.subEntities[s],!e||e(o,null))(r=a.k.getText("Entities",o.name))||(r=o.caption),(c=a.l.assign(new v,{id:o.name,text:r,items:[],isEntity:!0})).items=this._listByEntityWithFilter(o,e),c.items.length>0&&n.push(c)}var u=null;if(t.attributes)for(var l=t.attributes.length,d=0;d<l;d++)if(u=t.attributes[d],!e||e(t,u)){(r=a.k.getText("Attributes",u.id))||(r=u.caption);var c=a.l.assign(new v,{id:u.id,text:r,dataType:u.dataType});n.push(c)}return n},e.prototype._listByEntity=function(t,e,r){e=e||{};var n,o=[],i=[],s=null;if(t.subEntities)for(var u=t.subEntities.length,l=0;l<u;l++)if(s=t.subEntities[l],(!r||r(s,null))&&(!1!==e.addUIC&&!1!==s.useInConditions||!1!==e.addUIR&&!1!==s.useInResult||!1!==e.addUIS&&!1!==s.useInSorting)){n=a.k.getText("Entities",s.name)||s.caption;var d=a.l.assign(new v,{id:s.name,text:n,items:[],isEntity:!0,description:s.description}),c=a.l.assign({},e);c.includeRootData=!1,d.items=this._listByEntity(s,c,r),d.items.length>0&&o.push(d)}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=a.k.getText("Attributes",h.id)||h.caption,i.push(a.l.assign(new b(t),{id:h.id,text:n,dataType:h.dataType,lookupAttr:h.lookupAttr,description:h.description})));var y,g=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(o.sort(g),i.sort(g)),y=e.attrPlacement&&0!=e.attrPlacement?i.concat(o):o.concat(i),2==e.attrPlacement&&y.sort(g),e.includeRootData?((n=a.k.getText("Entities",t.name))||(n=t.caption),{id:t.name,text:n,items:y}):y},e.prototype.clear=function(){t.prototype.clear.call(this),this.operators=[],this.aggrFunctions=[]},e.prototype.addOrUpdateOperator=function(t){var e=a.l.findItemById(this.operators,t.id);return e||((e=new y).id=t.id,this.operators.push(e)),e.caption=t.caption,e.expr=t.expr||"",e.displayFormat=t.format,e.defaultOperand=new g,e.defaultOperand.kind=t.kind||d.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=a.l.findItemById(this.operators,t);r&&(e||a.l.removeArrayItem(this.operators,r),this.runThroughEntities((function(t,e){a.l.removeArrayItem(t.operators,r.id)})))},e.prototype.getOperatorIdsByDataType=function(t){switch(t){case a.b.String:case a.b.Memo:return"StartsWith,EndsWith,Contains,Equal,InList,NotStartsWith,NotEndsWith,NotContains,NotEqual,NotInList,IsNull,IsNotNull".split(",");case a.b.Guid:return"Equal,NotEqual".split(",");case a.b.Date:case a.b.DateTime:return"DateWithinToday,DateWithinThisWeek,DateWithinPrevWeek,DateWithinThisMonth,DateWithinPrevMonth,DateWithinThisYear,DateWithinPrevYear,DateBeforePrecise,DateAfterPrecise,DatePeriodPrecise,IsNull,IsNotNull".split(",");case a.b.Time:return"TimeBeforePrecise,TimeAfterPrecise,TimePeriodPrecise,IsNull,IsNotNull".split(",");case a.b.Byte:case a.b.Word:case a.b.Int32:case a.b.Int64:case a.b.Float:case a.b.Currency:case a.b.BCD:case a.b.Autoinc:case a.b.Unknown:return"Equal,Between,LessThan,LessOrEqual,GreaterThan,GreaterOrEqual,InList,NotEqual,NotBetween,NotInList,IsNull,IsNotNull".split(",");case a.b.Bool:return"IsTrue,NotTrue".split(",");default:for(var e=[],r=0,n=this.operators;r<n.length;r++){var o=n[r];o.appliedTypes.indexOf(t)>=0&&e.push(o.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 I(t),r=0,n=t.subEntities;r<n.length;r++){var o=n[r];e.addChild(this.createTreeNodeFromEntity(o))}return e},e.prototype.getEntitiesInQuery=function(t){if(t.model.id!==this.id)throw Error("Model mithmatch");for(var e=[],r=0,n=t.getColumns();r<n.length;r++){var o=n[r];o.enabled&&this.addEntityByExpression(e,o.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 n=r[e];if(n.id===t)return n}return null},e.prototype.fillEntitiesByCondtionGroup=function(t,e){for(var r=0,n=e.getConditions();r<n.length;r++){var o=n[r];if(o.isGroup())this.fillEntitiesByCondtionGroup(t,o);else for(var i=0,s=o.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 d=l[u];this.addEntityByExpression(t,d)}}}},e.prototype.addEntityByExpression=function(t,e){if(e.tag===f.EntityAttribute){var r=e.baseAttrId||e.value;if(r){var n=this.getAttributeById(r);n&&n.entity&&a.l.indexOfArrayItem(t,n.entity)<0&&t.push(n.entity)}}},e.prototype.findLink=function(t,e){for(var r=0,n=this.links;r<n.length;r++){var o=n[r];if(o.entityFrom==t&&o.entityTo==e)return o}return null},e.prototype.getLinksByEntity=function(t){for(var e=[],r=0,n=this.links;r<n.length;r++){var o=n[r];o.entityFrom!=t&&o.entityTo!=t||e.push(o)}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,n,o){return t.prototype.getEntityPathByAttr.call(this,e,r,n,o)},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 n=t.subEntities.length;for(r=0;r<n;r++){var o=this.getFirstUICAttrInEntity(t.subEntities[r]);if(o)return o}}}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,n){t(r)&&(n.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=a.k.getText("AggregateFunctions",t),r=e?e.caption:a.k.getText("Aggr"+t.replace(" ","")+"_Caption");if(r)return r;var n=a.l.findItemById(this.aggrFunctions,t);return n&&n.caption?n.caption:t},e.prototype.getAggrFunctionFormat=function(t){var e=a.k.getText("AggregateFunctions",t),r=e?e.displayFormat:a.k.getText("Aggr"+t.replace(" ","")+"_Format");if(r)return r;var n=a.l.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 g;e&&e.defaultOperand?(n.copyFrom(e.defaultOperand),n.defValue||(n.defValue=""),n.defText||(n.defText="")):(n.kind=d.Scalar,n.dataType=t.dataType,n.defValue="",n.defText="",n.editor=null);var o=n;return o.dataType===a.b.Unknown&&t&&(o.dataType=t.dataType),e&&r>=0&&e.operands&&e.operands[r-1]&&(o=a.l.assign(o,e.operands[r-1])),o.editor||(n.editor?o.editor=n.editor:n.kind===d.Query?o.editor.tag=E.SubQuery:t&&t.defaultEditor?o.editor=t.defaultEditor:o.dataType===a.b.Date||o.dataType===a.b.DateTime||o.dataType===a.b.Time?o.editor.tag=E.DateTime:o.editor.tag=E.Edit),o},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(a.l.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(a.l.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}(a.g),A=function(){function t(t){var e=this;this.parent=t,this.tag=f.Constant,this.kind=d.Scalar,this.dataType=a.b.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=d.Attribute,this._value=r.id,this.text=r.txt),void 0!==r.dtype&&(this.dataType=r.dtype),this.tag==f.EntityAttribute||this.tag==f.ParentEntityAttribute)this.kind=d.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 n=0;n<r.args.length;n++){var o=new t(this.parent);o.loadFromData(e,r.args[n]),this.args.push(o)}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==f.EntityAttribute||this.tag==f.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:!0,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 n=this.value;if(this.kind==d.Attribute&&t){var o=this.getModel().getAttributeById(t);if(!o)throw"No such entity attribute:"+t;this.dataType=o.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,n)},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 e=o.convertValue(t.value,t.dataType,this.dataType);this.setContent(e.length?e: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"}(C||(C={})),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"}(D||(D={})),function(t){t[t.None=0]="None",t[t.Ascending=1]="Ascending",t[t.Descending=2]="Descending"}(T||(T={}));var O,F,M=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._id=a.l.generateId("col"),this.caption="",this.sorting=T.None,this.sortIndex=-1,this.expr=new A(this),this.blockId=""}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,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===a.b.Unknown){var t=null;if(this.expr.func){if("COUNT"==this.expr.func||"CNTDST"==this.expr.func)return a.b.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),void 0!==this.sorting&&this.sorting!=T.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?C.SortingColumns:C.Columns,action:D.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"}(O||(O={})),function(t){t[t.EntityAttr=2]="EntityAttr",t[t.Operator=4]="Operator",t[t.Value=8]="Value",t[t.All=14]="All"}(F||(F={}));var k,q,L=function(){function t(t,e){this.query=t,this.linkType=n.All,this.parent=null,this._id=a.l.generateId("cond"),this.justAdded=!1,this.tag=e||O.Unknown,this.enabled=!0,this.operatorId="",this.blockId="",this.expressions=new Array,this.conditions=new Array}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(t.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:!0,configurable:!0}),t.prototype.getQuery=function(){return this.query},t.prototype.getModel=function(){return this.query.getModel()},t.prototype.getParent=function(){return this.parent},t.prototype.setParent=function(t){this.parent=t},t.prototype.getConditions=function(){return this.conditions},t.prototype.isEmpty=function(){return 0===this.conditions.length},t.prototype.isGroup=function(){return this.tag==O.Group||null==this.parent},t.prototype.getLevel=function(){var t=this.getParent();return t?t.getLevel()+1:0},t.prototype.isReadOnly=function(){return!1},t.prototype.setReadOnly=function(t){},t.prototype.isParameterized=function(){return!1},t.prototype.setParameterized=function(t){},t.prototype.isInJoin=function(){return!1},t.prototype.setInJoin=function(t){},t.prototype.clearConditions=function(){this.conditions=[]},t.prototype.addCondition=function(t){return t.setParent(this),this.conditions.push(t)},t.prototype.removeConditionAt=function(t){this.conditions.splice(t,1)},t.prototype.loadFromData=function(t,e){if(e){if(this.tag=e.tag,this.tag||(this.tag=!this.parent||this.conditions.length>0?O.Group:O.Simple),void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.disabled&&(this.enabled=!e.disabled),this.tag==O.Simple&&(this.operatorId=e.op,e.exprs))for(var r=0;r<e.exprs.length;r++){var n=new A(this);n.loadFromData(t,e.exprs[r]),this.expressions.push(n)}this.linkType=e.linking}},t.prototype.saveToData=function(){var t={};if(t.tag=this.tag,this.enabled||(t.enabled=this.enabled),this.tag==O.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==O.Group&&(t.linking=this.linkType),t},t.prototype.fireChangedEvent=function(t){void 0===t&&(t=F.All),this.query.fireChangedEvent({part:C.Conditions,action:D.Modify,changee:this,condPart:t})},t.prototype.getExpressionIndex=function(t){return this.expressions.indexOf(t,0)},t.prototype.expressionChanged=function(t,e){0==t.getIndex()&&t.tag==f.EntityAttribute&&this.tuneOperatorForAttr(t.value)},t.prototype.getOperatorId=function(){return this.operatorId},t.prototype.setOperatorId=function(t,e){void 0===e&&(e=!1);var r=this.operatorId;if(this.operatorId=t,!e){var n=this.getModel(),o=n.getOperatorById(t),i=this.expressions[0].value,s=n.getAttributeById(i);this.tuneValueExpressions(s,o,s.id,r)}},t.prototype.tuneOperatorForAttr=function(t){var e=this.getModel(),r=this.expressions[0].value,n=e.getAttributeById(r);if(null!=n){var o=this.getModel().getDefaultOperatorForAttr(n),i=this.operatorId;this.operatorId=o.id,this.tuneValueExpressions(n,o,t,i)}},t.prototype.tuneValueExpressions=function(t,e,r,n){var o=this.getModel();if(e){var i=this.expressions.length,s=(r&&o.getAttributeById(r),null);if(n&&(s=o.getOperatorById(n)),s&&s.paramCount==e.paramCount){for(var u=1;u<e.paramCount;){var l=o.getOperand(t,s,u);(y=o.getOperand(t,e,u)).dataType==a.b.Unknown&&(y.dataType=t.dataType);var d=y.editor&&y.editor.tag!==a.d.Unknown?y.editor:t.defaultEditor&&t.defaultEditor.tag!==a.d.Unknown?t.defaultEditor:new p;if(u>=i){var c=this.createValueExpr(y);this.expressions.push(c)}else{var h=this.expressions[u],f=this.createValueExpr(y);this.areCompitableEditors(l.editor,d)&&f.tryCopyValueFrom(h),this.expressions[u]=f}u++}i>u&&this.expressions.splice(u,i-u)}else{this.expressions.splice(1,this.expressions.length-1);for(u=1;u<e.paramCount;u++){var y;(y=o.getOperand(t,e,u)).dataType==a.b.Unknown&&(y.dataType=t.dataType);c=this.createValueExpr(y);this.expressions.push(c)}}}},t.prototype.areCompitableEditors=function(t,e){return e.tag!=E.CustomList&&e.tag!=E.List&&e.tag!=E.SqlList&&e.tag!=a.d.Unknown},t.prototype.addExpressionByOperand=function(t,e){void 0===e&&(e=null);var r=this.createValueExpr(t,e);return this.expressions.push(r),r},t.prototype.createValueExpr=function(t,e){void 0===e&&(e=null);var r=null==e,n=e||t.defValue,o=e||t.defText,i=new A(this);if(t.kind===d.Query)i.tag=f.Query,i.dataType=t.dataType,i.kind=t.kind,i.setContent(n,o,!0);else if(t.kind===d.Attribute){if(!r){var s=this.getModel().getFirstAttributeByFilter((function(e){return 1==e.useInConditions&&(!t.dataType||e.dataType==t.dataType)}));n=s?s.id:null}i.tag=f.EntityAttribute,i.kind=t.kind,i.dataType=t.dataType,i.setContent(n,o,!0)}else r&&(n=t.defValue&&""!=t.defValue?t.defValue:t.editor&&t.editor.defValue?t.editor.defValue:"",t.editor&&(o=t.editor.getValueText(n))),i.tag=f.Constant,i.dataType=t.dataType,i.kind=t.kind,i.setContent(n,o,!0),i._isDefaultValue=r;return i},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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),_=function(t){function e(r){var n=t.call(this,r)||this;return Error.captureStackTrace&&Error.captureStackTrace(n,e),n.name="InvalidQueryError",n}return R(e,t),e}(Error),P=function(){function t(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 a.e(this),this.root=new L(this,O.Group),this.extraConditions=new L(this,O.Group),this.columns=new Array,this.justsorted=new Array,this.id||this.regenerateId(),this.setDefaultName(),this.description="",this.model=t||new S,e&&this.loadFromData(e),this.attributeExprTag=r&&r.attrTag||f.EntityAttribute,this.clientListRequestHandler=r?r.clientListRequestHandler:new Array,this.serverListRequestHandler=r?r.serverListRequestHandler:new Array,this.timezoneOffset=(new Date).getTimezoneOffset(),this.aggrSettings=new a.a(this),r&&(this.parentQuery=r.parent),this.addChangedCallback((function(t){t.data&&(t.data.part&C.Columns)>0&&!t.data.aggregation&&n._enableAggregation&&n.updateAggregationSettings()&&n.fireChangedEvent({part:C.Aggregation})}))}return t.prototype.isModified=function(){return this._isModified},t.prototype.resetModified=function(){this._isModified=!1},Object.defineProperty(t.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==f.AggregateFunction}))}this._enableAggregation||this.aggrSettings.clear()},enumerable:!0,configurable:!0}),t.prototype.updateAggregationSettings=function(){for(var t=!1,e=this.getAggregationSettings(),r=e.groups.length-1;r>=0;r--){for(var n=e.groups[r],o=function(e){var r=n.columns[e];i.columns.find((function(t){return t.id===r}))||(n.columns.splice(e,1),t=!0)},i=this,s=n.columns.length-1;s>=0;s--)o(s);0==n.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},t.prototype.createSubQuery=function(){return new t(this.model)},t.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")},t.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==f.AggregateFunction}));if(r.length){for(var n=t.columns.filter((function(t){return t.enabled&&t.expr.tag==f.EntityAttribute})),o=[],i=0,s=r;i<s.length;i++){var u=s[i];o.push({id:u.id,func:u.expr.func}),t.changeColumnType(u,f.EntityAttribute)}for(var l=0,d=o;l<d.length;l++){var c=d[l];e.addAggregateColumn(c.id,c.func)}for(var h=0,p=n;h<p.length;h++){u=p[h];e.addGroup({columns:[u.id],name:u.caption})}e.addGrandTotals(),t.fireChangedEvent({part:C.Columns,wasModified:!1})}else{var y=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==f.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===a.b.Currency}))[0],g=t.getColumns().filter((function(e){return e.enabled&&e.expr.tag==f.EntityAttribute&&t.model.getAttributeById(e.expr.value).dataType===a.b.String}))[0];if(!y&&!e.hasAggregates()||!g)return;e.addGrandTotals().addAggregateColumn(y.id,"SUM").addGroup({columns:[g.id],name:"Default"})}}))},t.prototype.processQueryForAggregation=function(t){void 0===t&&(t=!1);var e=this.getAggregationSettings().getGroups();if(e.length>0){for(var r=e[e.length-1].columns,n=[],o=[],i=0,s=this.getColumns();i<s.length;i++){var a=s[i];r.indexOf(a.id)>=0?n.push(a):a.sorting!=T.None&&o.push(a)}var u=0;n.forEach((function(t){t.sorting==T.None&&(t.sorting=T.Ascending),t.sortIndex=u++})),o.forEach((function(t){t.sortIndex=u++})),t||this.fireChangedEvent({part:C.Columns,aggregation:!0,wasModified:!1})}},t.prototype.getAggregationSettings=function(){return this.aggrSettings},t.prototype.getColumnIds=function(t,e){return e=e||t,this.columns.slice(t,e-t+1).map((function(t){return t.id}))},t.prototype.validateColumns=function(t){for(var e=this.columns.filter((function(t){return t.enabled})).map((function(t){return t.id})),r=-1,n=0,o=t;n<o.length;n++){var i=o[n],s=e.indexOf(i);if(s<0)return!1;if(r>s)return!1;r=s}return!0},t.prototype.validateAggregate=function(t,e){var r=this.columns.filter((function(e){return e.enabled&&e.id===t}))[0],n=this.model.findAggrFunctionById(e);return!(!n||!r||n.appliedTypes.indexOf(r.expr.dataType)<0)},t.prototype.isEx=function(){return!1},t.prototype.reset=function(t){void 0===t&&(t=!0),t&&this.clear(),this.regenerateId(),this.setDefaultName(),this._isModified=!1,this.isNewbie=!0},t.prototype.hasEnabledAggrColumns=function(){return this.columns.filter((function(t){return t.enabled&&t.expr.tag===f.AggregateFunction})).length>0},t.prototype.setDefaultName=function(){return this.setName(a.k.getText("NewQueryName")),this.getName()},t.prototype.validate=function(t){t=t||{};var e="EntityAttribute isn't declared in the model: ";if(!this.model)throw new _("Model is not declared");if(this.columns)for(var r=0,n=this.columns;r<n.length;r++){var o=n[r];if(o.expr.tag==f.EntityAttribute||o.expr.tag===f.ParentEntityAttribute){if(!this.model.getAttributeById(o.expr.value))throw new _(e+o.expr.value)}else if(o.expr.tag===f.AggregateFunction){if(!this.model.getAttributeById(o.expr.args[0].value))throw new _(e+o.expr.args[0].value)}else if(o.expr.tag!==f.CustomSql)throw new _("The expression has wrond tag: "+o.expr.tag)}this.root&&this.root.getConditions()&&this.validateConditionGroup(this.root,t)},t.prototype.getAggregatedColumns=function(){return this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===f.AggregateFunction}))},t.prototype.tryValidate=function(t){try{return this.validate(t),!0}catch(t){if(t instanceof _)return!1;throw t}},t.prototype.validateConditionGroup=function(t,e){if(t.isGroup())for(var r=0,n=t.getConditions();r<n.length;r++){var o=n[r];o.enabled&&this.validateConditionGroup(o,e)}else if(t.expressions[0].tag===f.EntityAttribute){var i=t.expressions[0].value;if(!this.model.getAttributeById(i))throw new _("EntityAttribute isn't declared in the model: "+i);if(!e.checkExpressions)return;for(var s=1;s<t.expressions.length;s++){var u=t.expressions[s];if(u.tag===f.Constant&&a.l.isNumericType(u.dataType)){if(!u.value)continue;for(var l=0,c=u.kind===d.List?u.value.split(/\s*,\s*/):[u.value];l<c.length;l++){var h=c[l],p=+h;if(isNaN(p))throw new _("Expression constant is NaN in condition:"+t.id);if(a.l.isIntType(u.dataType)&&p!=parseInt(h,10))throw new _("Expression constant is wrong interger in condition: "+t.id)}}}}},t.prototype.loadFromDataOrJson=function(t,e){t&&("string"==typeof t?this.loadFromJson(t,e):this.loadFromData(t,e))},t.prototype.loadFromJson=function(t,e){var r=JSON.parse(t);this.loadFromData(r,e)},t.prototype.loadFromData=function(t,e){var r=this;e=a.l.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 o=t.root.conds[n];if(!o.conds||this.isEx()){var i=this.createCondition();i.loadFromData(this.model,o),this.root.addCondition(i)}else console.error("Community version doesn't support working with groups.")}if(this.name=t.name,this.description=t.desc,this.justsorted=[],t.justsortcols)for(n=0;n<t.justsortcols.length;n++){(s=this.createColumn(!0)).loadFromData(this.model,t.justsortcols[n]),this.justsorted.push(s)}if(t.cols)for(n=0;n<t.cols.length;n++){var s;(s=this.createColumn()).loadFromData(this.model,t.cols[n]),this.columns.push(s)}if(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 d=l[u];this.addDrillDown().loadFromData(d)}}e.changeStatus&&(this.isNewbie=!1,this._isModified=!1),e.validate&&this.validate()},t.prototype.addDrillDown=function(){var t=this.model.createQuery();return t.parentQuery=this,this.drillDowns.push(t),t},t.prototype.getDrillDowns=function(){return this.drillDowns},t.prototype.getParentQuery=function(){return this.parentQuery},t.prototype.findColumnById=function(t){for(var e=0,r=this.columns;e<r.length;e++){var n=r[e];if(n.id===t)return n}return null},t.prototype.getModel=function(){return this.model},t.prototype.setModel=function(t){this.model=t},t.prototype.loadModelData=function(t){this.model.setData(t)},t.prototype.toJSON=function(){return JSON.stringify(this.toJSONData())},t.prototype.toJSONData=function(){var t=this,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=[];for(r=0;r<this.justsorted.length;r++)e.justsortcols.push(this.justsorted[r].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 n=e.getConditions(),o=0;o<n.length;o++)!n[o].isGroup()||t.isEx()?r.conds.push(n[o].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 o=0,i=this.drillDowns;o<i.length;o++){var s=i[o];e.dds.push(s.toJSONData())}}return e.timezoneOffset=this.timezoneOffset,e.locale=a.k.getCurrentLocale(),e},t.prototype.isEmptyConditions=function(){return this.root.isEmpty()},t.prototype.isEmptyColumns=function(){return!this.columns||0===this.columns.length},t.prototype.isEmpty=function(){return this.isEmptyColumns()&&this.isEmptyConditions()},t.prototype.clear=function(){this._enableAggregation=!1,this.aggrSettings.clear(),this.clearColumns(),this.clearConditions(),this.clearExtraConditions(),this.innerData={},this.extraData={}},t.prototype.clearColumns=function(){this.columns=[],this.justsorted=[]},t.prototype.clearConditions=function(){this.root.clearConditions(),this.root.linkType=n.All,this.root.enabled=!0},t.prototype.clearExtraConditions=function(){this.extraConditions.clearConditions()},t.prototype.clearDrillDowns=function(){this.drillDowns=[]},t.prototype.getId=function(){return this.id},t.prototype.setId=function(t){this.id=t},t.prototype.regenerateId=function(){this.id=a.l.generateId("quer")},t.prototype.getName=function(){return this.name},t.prototype.setName=function(t){this.name=t},t.prototype.getDescription=function(){return this.description},t.prototype.setDescription=function(t){this.description=t},t.prototype.getColumns=function(){return this.columns},t.prototype.getUsedInTotalsColumns=function(){if(0===this.getAggregatedColumns().length)return[];var t=this.getColumns().filter((function(t){return t.enabled&&t.expr.tag===f.EntityAttribute}));return t.length&&t.pop(),t},t.prototype.getJustSortedColumns=function(){return this.justsorted},t.prototype.getSortedColumns=function(){for(var t=new Array,e=this.getColumns().concat(this.getJustSortedColumns()),r=0;r<e.length;r++){var n=e[r];n.sortIndex>=0&&t.push(n)}return t.sort((function(t,e){return t.sortIndex-e.sortIndex})),t},t.prototype.getColumnSortIndex=function(t){if(t.sorting!=T.None){if(t.sortIndex<0){var e=this.getColumns().concat(this.getJustSortedColumns());return a.l.indexOfArrayItem(e,t)}return t.sortIndex}return-1},t.prototype.createColumn=function(t){return void 0===t&&(t=!1),new M(this,t)},t.prototype.getColumnById=function(t){return a.l.findItemById(this.columns,t)},t.prototype.addColumn=function(t,e){var r,n=t.justsorted?this.justsorted:this.columns;if(t.column)r=t.column;else{r=this.createColumn(t.justsorted);var o=void 0;if(t.attribute)o=t.attribute;else{if(!t.attributeId)throw new Error("Not enought data: addColumn");if(!(o=this.model.getAttributeById(t.attributeId)))throw new Error("Incorrect attribute id ("+t.attributeId+"): addColumn")}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=f.CustomSql,r.expr.baseAttrId=o.id,r.expr.sql=t.cusomtSql,r.expr.kind=d.Query,r.expr.dataType=a.b.Unknown;else if(t.aggrFuncId){var i=t.aggrFuncId;r.caption=o.caption+" "+this.model.getAggrFunctionCaption(t.aggrFuncId),r.expr.tag=f.AggregateFunction,r.expr.func=t.aggrFuncId,r.expr.kind=d.Scalar,r.expr.dataType="COUNT"==i||"CNTDST"==i?4:o.dataType,r.expr.distinct=!1;var s=new A(r);s.setValue(o.id,!0),s.tag=f.EntityAttribute,s.dataType=o.dataType,r.expr.args.push(s)}else r.caption=o.caption,r.expr.setValue(o.id,!0),r.expr.tag=f.EntityAttribute,r.expr.dataType=o.dataType;r.caption=t.caption||r.caption,r.sorting=t.sorting||T.None,r.sortIndex=t.sortIndex||-1,r.enabled=a.l.getIfDefined(t.enabled,!0),r.setReadOnly(a.l.getIfDefined(t.readonly,!1))}return t.index&&t.index>=0&&t.index<n.length?n.splice(t.index,0,r):n.push(r),r},t.prototype.addColumnObj=function(t,e,r){var n=this.columns;void 0===t.length?"number"==typeof e?n.splice(e,0,t):n.push(t):"number"==typeof e?n.push.apply(n,[e,0].concat(t)):n.push.apply(n,[].concat(t))},t.prototype.changeColumnType=function(t,e,r){if(!t.isJustSorted())if(r=r||{},t.caption=void 0!==r.caption?r.caption:"",e===f.AggregateFunction){if(!r.funcId)throw Error('"funcId" argument is not defined');if(t.expr.tag==f.AggregateFunction)return void(t.expr.func=r.funcId);(u=new A(t)).tag=f.AggregateFunction,u.func=r.funcId,u.distinct=!1,u.dataType="COUNT"==r.funcId||"CNTDST"==r.funcId?4:t.expr.dataType;var n=new A(t);n.loadFromData(this.model,t.expr.saveToData()),u.args.push(n),t.expr=u}else if(e===f.CustomSql){var o=t.expr.tag==f.AggregateFunction?t.expr.args[0].value:t.expr.value,i="";this.model&&(i=this.model.getAttributeById(o).expr);var s=new A(t);s.tag=f.CustomSql,s.dataType=a.b.String,s.sql=i,s.baseAttrId=o,t.expr=s}else if(e===f.EntityAttribute){if(t.expr.tag===f.EntityAttribute||t.expr.tag===f.ParentEntityAttribute)return;var u,l=t.expr.tag===f.CustomSql?t.expr.baseAttrId:t.expr.args[0].value,d=this.model.getAttributeById(l);(u=new A(t)).tag=f.EntityAttribute,u.dataType=null!=d?d.dataType:a.b.Unknown,u.setValue(l,!0),t.expr=u}},t.prototype.moveColumn=function(t,e){var r=this.getColumns();a.l.moveArrayItem(r,t,e)},t.prototype.removeColumn=function(t,e){var r=t.isJustSorted()?this.getJustSortedColumns():this.getColumns();a.l.removeArrayItem(r,t)},t.prototype.addConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},t.prototype.addExtraConditionGroup=function(t,e){return void 0===e&&(e=!0),console.error("Community version doesn't support working with groups."),null},t.prototype.createCondition=function(t){return void 0===t&&(t=O.Simple),new L(this,t)},t.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=a.l.getIfDefined(t.enabled,!0),n.setReadOnly(a.l.getIfDefined(t.readonly,!1)),n},t.prototype.addSimpleExtraCondition=function(t){return t.parent=t.parent||this.extraConditions,this.addSimpleCondition(t)},t.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(O.Simple);n.setOperatorId(e.id,!0);var o=new A(n);o.setValue(t.id,!0),o.tag=this.attributeExprTag,o.kind=d.Attribute,o.dataType=t.dataType,n.expressions.push(o);var i=this.getModel(),s=e.paramCount,u=a.l.fillArray(new Array(s-1),null);null!=r&&(Array.isArray(r)?a.l.copyArrayTo(r,u):s>0&&(u[0]=r));for(var l=u.length,c=0;c<l;c++){var h=i.getOperand(t,e,c+1);n.addExpressionByOperand(h,u[c])}return n},t.prototype.removeColumns=function(t,e){var r=t.filter((function(t){return t.isJustSorted()})),n=t.filter((function(t){return!t.isJustSorted()}));function o(t,e){for(var r=e.length,n=0;n<r;n++){var o=t.indexOf(e[n]);o>=0&&t.splice(o,1)}}n.length>0&&o(this.getColumns(),n),r.length>0&&o(this.getJustSortedColumns(),r)},t.prototype.fireProcessEvent=function(t){this.eventEmitter.fire("query.process",t)},t.prototype.fireChangedEvent=function(t,e,r){t=t||{part:C.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 n=t||{part:C.All};this.eventEmitter.fire("query.change",n,t.postpone||0)},t.prototype.fireColumnsChangedEvent=function(t,e,r){void 0===r&&(r=!1),this.fireChangedEvent({part:r?C.SortingColumns:C.Columns,action:t,changee:e})},t.prototype.fireConditionsChangedEvent=function(t,e){this.fireChangedEvent({part:C.Conditions,action:t,changee:e})},t.prototype.runThroughConditions=function(t){var e=function(r){for(var n=0;n<r.getConditions().length;n++){var o=r.getConditions()[n];o.isGroup()?e(o):t&&t(o)}};e(this.getRootCondition())},t.prototype.getOneValueForAttr=function(t){var e=null;return this.runThroughConditions((function(r){if(r.enabled){var n=r.expressions[0],o=r.getOperatorId();n.value!=t||!r.expressions[1]||"Equal"!=o&&"InList"!=o&&"StartsWith"!=o||(e=r.expressions[1].value)}})),e},t.prototype.getRootCondition=function(){return this.root},t.prototype.addProcessCallback=function(t){return this.eventEmitter.subscribe("query.process",t)},t.prototype.removeProcessCallback=function(t){this.eventEmitter.unsubscribe("query.process",t)},t.prototype.addChangedCallback=function(t){return this.eventEmitter.subscribe("query.change",t)},t.prototype.removeChangedCallback=function(t){this.eventEmitter.unsubscribe("query.change",t)},t.prototype.getConditionsText=function(){var t=this,e=this.getModel();if(!e)return"";var r=function(i){var s,u,l="",c="Conj"+o.linkTypeToStr(i.linkType),h=a.k.getText(c);for(u=0;u<i.getConditions().length;u++){s="";var p=i.getConditions()[u];if(p.enabled||void 0===p.enabled)if(p.isGroup())(s=r(p))&&(s="("+s+")");else for(var y=p.getOperatorId(),g=e.getOperatorById(y),m=o.parseOperatorFormat(g),v=m.length,b=0;b<v;b++){var x=m[b],E=x.text;if("expression"==x.type){var C=p.expressions[x.index];if(C.kind==d.Attribute||C.tag==f.EntityAttribute){var D=e.getAttributeById(C.value);E=e.getAttributeText(D,"{entity} {attr}")}else if(E=C.getText(),t.model.isDateMacro(E)||t.model.isTimeMacro(E)){var T=E.substring(3,E.length-2);E=a.k.getText(T)||E}}b>0&&(s+=" "),s+=E}s&&(u>0&&l&&(l+=" "+h+" "),l+=s)}return i.linkType!=n.None&&i.linkType!=n.NotAll||(l="not ( "+l+" )"),l};return r(this.getRootCondition())},t.prototype.getConditionsTextAsHtml=function(){var t=this,e=this.getModel();if(!e)return'<div class="eqjs-query-text"></div>';var r=function(e){if(e.kind==d.Query)return"<"+e.getText()+">";if(e.kind==d.List)return"["+e.getText()+"]";if(e.dataType==a.b.String||e.dataType==a.b.Memo||e.dataType==a.b.FixedChar)return"""+e.getText()+""";var r=e.getText();if(t.model.isDateMacro(r)||t.model.isTimeMacro(r)){var n=r.substring(3,r.length-2);r=a.k.getText(n)||r}return r},i=function(t){var s,u,l="",c="Conj"+o.linkTypeToStr(t.linkType),h='<span class="eqjs-query-text-conj">'+a.k.getText(c)+"</span>";for(u=0;u<t.getConditions().length;u++){s="";var p=t.getConditions()[u];if(p.enabled||void 0===p.enabled)if(p.isGroup())(s=i(p))&&(s="("+s+")");else for(var y=p.getOperatorId(),g=e.getOperatorById(y),m=o.parseOperatorFormat(g),v=m.length,b=0;b<v;b++){var x=m[b],E=x.text;if("expression"==x.type){var C=p.expressions[x.index];if(C.kind==d.Attribute||C.tag==f.EntityAttribute){var D=e.getAttributeById(C.value);E='<span class="eqjs-query-text-attr">'+e.getAttributeText(D,"{entity} {attr}")+"</span>"}else E='<span class="eqjs-query-text-expr">'+r(C)+"</span>"}else"operator"==x.type&&(E='<span class="eqjs-query-text-op">'+E+"</span>");b>0&&(s+=" "),s+=E}s&&(u>0&&l&&(l+=" "+h+" "),l+=s)}return t.linkType!=n.None&&t.linkType!=n.NotAll||(l='<span class="eqjs-query-text-conj">not</span> ( '+l+" )"),l};return'<div class="eqjs-query-text">'+i(this.getRootCondition())+"</div>"},t}(),Q=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 n=localStorage.getItem(e.queryListKey);n&&t(JSON.parse(n)),t([])}catch(t){r(t)}}))},t.prototype.newQuery=function(t){var e=this;return new Promise((function(r,n){var o=new P(e.context.getModel());o.reset(),o.setDefaultName(),t&&(t.query&&o.loadFromData(t.query.toJSONData()),t.queryId&&o.setId(t.queryId),t.name&&o.setName(t.name),t.description&&o.setDescription(t.description)),e._saveQuery(o),r(o.toJSONData())}))},t.prototype.loadQuery=function(t){var e=this;return new Promise((function(r,n){try{var o=localStorage.getItem(e.queryKeyPrefix+"-"+t.queryId);throw o&&r(JSON.parse(o)),new Error("Query is not found: "+t.queryId)}catch(t){n(t)}}))},t.prototype.saveQuery=function(t){var e=this;return new Promise((function(r,n){try{t.modelId||e.context.getModel().getId();var o=t.query||e.context.getQuery();e._saveQuery(o),r(null)}catch(t){n(t)}}))},t.prototype._saveQuery=function(t){var e=[],r=localStorage.getItem(this.queryListKey);r&&(e=JSON.parse(r));var n=a.l.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,n){try{t.modelId||e.context.getModel().getId();var o=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!=o})),localStorage.setItem(e.queryListKey,JSON.stringify(i)),localStorage.removeItem(e.queryKeyPrefix+"-"+o),r()}catch(t){n(t)}}))},t}(),N=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}(),B=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)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),j=function(t){function e(e){return t.call(this,e)||this}return B(e,t),e.prototype.init=function(){},e.prototype.sendLoadModelRequest=function(t){var e=this,r=this.getContext(),n=r.getServices().getHttpClient(),o=r.resolveEndpoint("GetModel",{modelId:t.modelId});n.get(o).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}(N),G=function(){function t(t){this.context=t}return t.prototype.fetchData=function(t){var e=t.query||this.context.getQuery(),r=e.getId(),n={options:t.options};void 0!==t.queryId?n.queryId=t.queryId:n.query=e.toJSONData(),t.debug&&(n.debug=t.debug),t.chunk&&(n.chunk=t.chunk),t.data&&(n.data=t.data),void 0!==t.aux&&(n.aux=t.aux);var o=this.context.resolveEndpoint("FetchData",{modelId:e.getModel().getId(),queryId:r});return this.context.getServices().getHttpClient().post(o,n).then((function(t){return t}))},t}(),U=function(){function t(t){this.context=t}return t.prototype.syncQuery=function(t){var e=(t=t||{}).query||this.context.getQuery(),r=t.options||{},n={query:e.toJSONData(),options:r};t.data&&(n.data=t.data);var o=this.context.resolveEndpoint("SyncQuery",{modelId:e.getModel().getId(),queryId:e.getId()});return this.context.getServices().getHttpClient().post(o,n).then((function(t){return t}))},t}(),V=function(){function t(t){this.context=t}return t.prototype.loadValueList=function(t){var e=t.modelId||this.context.getModel().getId(),r=a.l.assign({modelId:e},t.params).editorId,n=this.context.getServices().getHttpClient(),o=this.context.resolveEndpoint("GetValueList",{modelId:e,listId:r}),i={};return t&&t.params&&t.params.queryParams&&(i=t.params.queryParams),n.get(o,{queryParams:i}).then((function(t){if(t&&t.values)return t.values;throw new Error('Wrong response format. No "values" property')}))},t}(),W=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"}),n=this.context.getServices().getHttpClient().post(r,{query:e.toJSONData()}),o=n.getRequest();return n.then((function(e){var r=new Blob([e]),n=o.getXMLHttpRequest().getResponseHeader("Content-Disposition").match(/filename="(.*)"/)[1];if(t.fileName&&(n=t.fileName+n.substring(n.lastIndexOf("."))),window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,n);else{var i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=window.URL.createObjectURL(r),i.download=n,i.click(),window.URL.revokeObjectURL(i.href),document.body.removeChild(i)}}))},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}(),H=function(){function t(t){this.context=t,this.levels={}}return t.prototype.getAggregateData=function(t,e){var r=this;return new Promise((function(n,o){var i=function(t){var i=r.groupKeyToStr(e),s=t.get(i);s?n(s):o("Can't find data for "+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 n=0,o=r.receivedCallbacks;n<o.length;n++){(0,o[n])(r.data)}r.receivedCallbacks=[]},t.prototype.updateAggregateData=function(t,e,r){var n=this.getLevelDesc(t,!0),o=this.groupKeyToStr(e);n.data.set(o,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}(),J=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 H(this.context);var e=this.context.createQuery();e.loadFromData(this.context.getQuery().toJSONData());for(var r=this.context.getQuery().getAggregationSettings(),n=r.getAggregates().map((function(t){return t.colId})),o=e.getColumns().filter((function(t){return n.indexOf(t.id)<0})),i=0;i<o.length;i++)o[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}(),z=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 a.f,this.httpClient.defaultHeaders["x-eqjs-version"]="7.2.0",this.modelResolver=function(t){return new S},this.modelStorageResolver=null,this.queryResolver=function(t){return new P(t.getModel())},this.modelLoaderResolver=function(t){return new j(t)},this.queryStorageResolver=function(t){return new Q(t)},this.querySynchronizerResolver=function(t){return new U(t)},this.vlrResolver=function(t){return new V(t)},this.dataFetcherResolver=function(t){return new G(t)},this.queryFileLoaderResolver=function(t){return new W(t)},this.aggrCalculatoResolver=function(t){return new J(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}(),K=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 o={chunk:t,success:function(n){for(var o=new a.c({loader:e.context.dataLoader,chunkSize:e.context.resultTable.chunkSize}),i=n.resultSet,s=0,u=i.cols;s<u.length;s++){var l=u[s];o.columns.add(l)}o.setTotal(n.meta.totalRecords);for(var d=0,c=i.rows;d<c.length;d++){var h=c[d];o.addRow(h)}var p=0;n.meta&&n.meta.totalRecords&&(p=n.meta.totalRecords),r({table:o,total:p,hasNext:!t.needTotal||t.offset+t.limit<p})},error:function(t){return n(t)}};e.context.debugMode&&(o.debug="Data Chunk. Offset: "+t.offset),e.context.fetchDataChunk(o)})),this.dataLoadPromise},t}(),Y=r(1);!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"}(k||(k={})),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"}(q||(q={}));var $,X=function(){function t(t){this.models=[],t&&a.l.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"}($||($={}));var Z=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",n=t.query||this.context.getQuery(),o=n.getModel().getId(),i={settings:t.settings};void 0!==t.queryId?i.queryId=t.queryId:i.query=n.toJSONData();var s=this.context.resolveEndpoint("ExportResult",{modelId:o,format:r}),a=e.post(s,i,{responseType:this.responseType}),u=a.getRequest();return a.then((function(t){var e=new Blob([t]),r=u.getXMLHttpRequest().getResponseHeader("Content-Disposition").match(/filename="(.*)"/)[1];if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(e,r);else{var n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=window.URL.createObjectURL(e),n.download=r,n.click(),window.URL.revokeObjectURL(n.href),document.body.removeChild(n)}}))},t}(),tt=function(){return tt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},tt.apply(this,arguments)},et=function(){function t(){var t=this;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:a.k.getText(t)}}))),!0},_DSTE:function(e,r){return r(t.getModel().getAllTimeMacros().map((function(t){return{id:"${{"+t+"}}",text:a.k.getText(t)}}))),!0}},this._listRequestHandler=function(e,r){if(null!=e&&e.listName){var n=t.getQuery(),o=a.l.assign({listName:e.listName},e.editorParams),i={},s=/@{{(.+?)}}/;for(var u in o)if(o[u]){var l=o[u].match(s);if(l){var d=n.getOneValueForAttr(l[1]);d||(d=""),i[u]=o[u].replace(s,d)}}var c={listName:i.listName,editorId:e.editorId,queryParams:i},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:c,success:function(n){n&&t.addListToCache(e,n),r(n)},error:function(t){r(null)}})}}},this.baseEndpoint="api/easyquery",this.eqServices=new z(this),this.widgets=new Array,this.eventEmitter=new a.e(this),this.exporters=new Map,this.endpoints=new Map,this.dataLoader=new K(this),this.resultTable=new a.c({loader:this.dataLoader,onUpdate:this.onResultTableUpdate.bind(this)}),this.resultTable.id="ResultTable",this.errorHandlerId=this.addEventListener("error",(function(t,e){e.result=$.Error;var r=e.action?e.action+" error":"Error",n=e.text?e.text:"";e.sourceError&&e.sourceError.message!==n&&(n+="\n"+e.sourceError),console.error(r+": "+n)}))}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 n=new Z(r);return n.setFormat(t,e),n}))},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 n=r.match(this.endpointVarsRegex);if(n)for(var o=0,i=n;o<i.length;o++){var s=i[o],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 ["+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",o.combinePath(t,"models/{modelId}")),this.setEnpointIfNotExist("GetQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SaveQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("SyncQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}/sync")),this.setEnpointIfNotExist("NewQuery",o.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("RemoveQuery",o.combinePath(t,"models/{modelId}/queries/{queryId}")),this.setEnpointIfNotExist("GetQueryList",o.combinePath(t,"models/{modelId}/queries")),this.setEnpointIfNotExist("FetchData",o.combinePath(t,"models/{modelId}/fetch")),this.setEnpointIfNotExist("GetValueList",o.combinePath(t,"models/{modelId}/valuelists/{listId}")),this.setEnpointIfNotExist("ExportResult",o.combinePath(t,"models/{modelId}/export/{format}")),this.setEnpointIfNotExist("GetQueryFile",o.combinePath(t,"models/{modelId}/getqueryfile/{format}")),this.setEnpointIfNotExist("UploadQueryFile",o.combinePath(t,"models/{modelId}/uploadqueryfile"))},t.prototype.initStart=function(){this.servicesInitialized=!0},t.prototype.init=function(t){var e=this;(this.servicesInitialized||this.initStart(),void 0!==(t=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&&a.k.setCurrentLocale(t.locale),t.localeSettings&&a.k.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)for(var r=0,n=t.serverExporters;r<n.length;r++){var o=n[r],i="csv"==o||"excel-html"==o?"":"arraybuffer";this.registerServerExporter(o,i)}var s=this.getQuery();t.defaultQueryId&&s.setId(t.defaultQueryId),this.widgets.forEach((function(r){var n={};t.widgets&&t.widgets[r.getWidgetType()]&&(n=t.widgets[r.getWidgetType()]),r.init(e,n)})),this.loadModelOnStart?this.loadDefaultModel():this.fireEvent("ready")},Object.defineProperty(t.prototype,"backendInfo",{get:function(){return this._backendInfo},enumerable:!0,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=k.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===$.Error&&this.throwError(t),this.widgets.forEach((function(t){t.belongsToGroup(e)&&t.onProcessEnd()}))},t.prototype.throwError=function(t){t.result=$.Error,this.eventEmitter.fire("error",t)},t.prototype.loadDefaultModel=function(){var t=this;this.loadModel({modelId:this.defaultModelId,silent:!0,success:function(){t.refreshWidgets(k.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(k.Query),t.fireEvent("ready")}}):(t.refreshWidgets(k.Query),t.fireEvent("ready"))}})},t.prototype.clearQuery=function(){var t=this.getQuery();t.clear(),t.fireChangedEvent({part:C.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){a.k.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:q.GetValueList,text:"Loading values"},k.Result),this.eqServices.getValueListResolver().loadValueList(t).then((function(r){e.endProcess({result:$.Success,action:q.GetValueList,text:"Values loaded"},k.Result),t.success&&t.success(r)})).catch((function(r){var n="Can't load the value list for editor "+(t&&t.params?t.params.editorId:"undefined")+".\n "+r.message;e.endProcess({result:$.Error,action:q.GetValueList,text:n,sourceError:r},k.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",n=t.silent||!1;return this.startProcess({action:q.LoadModel,text:"Loading model: "+r},k.Model),this.eqServices.getModelLoader().startModelLoading(t).then((function(o){return o?(e.loadModelFromData(o),e.dataModel.isEmpty()&&console.warn("Empty model has been loaded. Model ID: "+e.dataModel.getId())):console.warn("Model has not been changed."),e.fireEvent("loadModel"),e.endProcess({result:$.Success,action:q.LoadModel,text:"Model loaded: "+r},k.Model),n||(e.clearQuery(),e.clearResult(),e.refreshWidgets()),t.success&&t.success(e.getModel()),e.getModel()})).catch((function(n){var o="Can't load model "+r+".\n "+n.message;return e.endProcess({result:$.Error,action:q.LoadModel,text:o,sourceError:n},k.Model),t.error&&t.error(o,"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,n=t.silent||!1;e.beforeLoadQuery&&e.beforeLoadQuery(e,t),e.startProcess({action:q.LoadQuery,text:"Query loading: "+r},k.Query),e.eqServices.getQueryStorage().loadQuery(t).then((function(o){o&&e.query.loadFromData(o,{validate:!1}),e.fireEvent("loadQuery"),e.endProcess({result:$.Success,action:q.LoadQuery,text:"Query loaded: "+r},k.Query),e.query.resetModified(),n||(e.query.fireChangedEvent({part:C.Properties,wasModified:e.query.isModified()}),e.refreshWidgets()),t.success&&t.success(e.query)})).catch((function(r){var n=e.getQuery();r.message="Can't load query ["+n.getId()+"]\n"+(r.message||""),t.error&&t.error(r.message,q.LoadQuery),e.endProcess({result:$.Error,action:q.LoadQuery,text:r.message,sourceError:r},k.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 "+t.message;e.throwError({action:q.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 n="Can't load the list of available queries.\n "+r.message;t.error?t.error(n,"LoadQueryList"):e.throwError({action:q.LoadQueryList,text:n,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 n=t.silent||!1,o=!0;void 0!==t.useStorage&&(o=t.useStorage);var i=function(){var t=e.getQuery();t.isNewbie=!0,n||t.fireChangedEvent({part:C.All,wasModified:t.isModified()})};o?(this.startProcess({action:q.NewQuery,text:"New query creation..."},k.Query),this.eqServices.getQueryStorage().newQuery(t).then((function(r){r&&e.query.loadFromData(r),e.endProcess({result:$.Success,action:q.NewQuery,text:"A new query has been created"},k.Query),i(),t.success&&t.success()})).catch((function(r){var n="Can't create a new query.\n"+r.message;e.endProcess({result:$.Error,action:q.NewQuery,text:n,sourceError:r},k.Query),t.error&&t.error(n,"NewQuery")}))):i();return this.query},t.prototype.saveQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:q.SaveQuery,text:"Query saving: "+r.getId()},k.Query),this.eqServices.getQueryStorage().saveQuery(t).then((function(n){e.endProcess({action:q.SaveQuery,result:$.Success,text:"Query saved: "+r.getId()},k.Query),n&&r.loadFromData(n),r.resetModified(),r.isNewbie=!1,t.success&&t.success()})).catch((function(n){var o="Can't save query "+r.getId()+".\n "+n.message;e.endProcess({action:q.SaveQuery,result:$.Error,text:o,sourceError:n},k.Query),t.error&&t.error(o,q.SaveQuery)}))},t.prototype.removeQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.startProcess({action:q.RemoveQuery,text:"Query deleting: "+r.getId()},k.Query),this.eqServices.getQueryStorage().removeQuery(t).then((function(){r.reset(),e.endProcess({action:q.RemoveQuery,result:$.Success,text:"Query deleted: "+r.getId()},k.Query),t.success&&t.success()})).catch((function(n){var o="Can't remove query "+r.getId()+".\n "+n.message;e.endProcess({action:q.RemoveQuery,result:$.Error,text:o,sourceError:n},k.Query),t.error&&t.error(o,"RemoveQuery")}))},t.prototype.syncQuery=function(t){var e=this;t=t||{};var r=this.getQuery();this.beforeSyncQuery&&this.beforeSyncQuery(this,t),this.startProcess({action:q.SyncQuery,text:"Query syncing: "+r.getId()},k.Query),this.eqServices.getQuerySynchronizer().syncQuery(t).then((function(n){if(e.resultStatement=n&&n.statement?n.statement:"",e.fireEvent("syncQuery"),e.refreshWidgets(k.Statement),e.endProcess({result:$.Success,action:q.SyncQuery,text:"Query synced: "+r.getId()},k.Query),n){if(n.querySaved){var o=n.query;o&&(r.setId(o.id),r.setName(o.name),r.setDescription(o.desc),r.extraData=o.extraData),r.resetModified(),e.refreshWidgets(k.QueryStatus)}t.success&&t.success(n)}})).catch((function(n){var o="Can't synchronize query "+r.getId()+".\n "+n.message;e.endProcess({result:$.Error,action:q.SyncQuery,text:o,sourceError:n},k.Query),t.error&&t.error(o,"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(tt(tt({},t),{success:function(r){if(r.statement&&(e.resultStatement=r.statement,e.refreshWidgets(k.Statement)),e.getServices().getAggregatesCalculator().reset(),e.resultContent=r,r.resultSet){e.resultTable.clear(),e.resultTable.id=e.query.getId();for(var n=r.resultSet,o=0,i=n.cols;o<i.length;o++){var s=i[o];e.resultTable.columns.add(s)}r.meta&&void 0!==r.meta.totalRecords&&e.resultTable.setTotal(r.meta.totalRecords);var a=n.rows.length;e.resultTable.elasticChunks&&a===t.chunk.limit&&n.rows.splice(n.rows.length-1,1);for(var u=0,l=n.rows;u<l.length;u++){var d=l[u];e.resultTable.addRow(d)}e.resultTable.elasticChunks&&(e.resultTable.total=a<t.chunk.limit?n.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:q.GetQueryFile,text:"Getting query file: "+r.getId()},k.Query),this.getServices().getQueryFileLoader().getQueryFile(t).then((function(){e.endProcess({result:$.Success,action:q.GetQueryFile,text:"Getting query file: "+r.getId()},k.Result),t.success&&t.success()})).catch((function(n){var o="Can't get file for query "+r.getId()+".\n "+n.message;e.endProcess({result:$.Error,action:q.GetQueryFile,text:o,sourceError:n},k.Query),t.error&&t.error(o,"GetQueryFile")}))},t.prototype.uploadQueryFile=function(t){var e=this,r=this.getQuery();this.startProcess({action:q.UploadQueryFile,text:"Uploading query file: "+r.getId()},k.Query),this.getServices().getQueryFileLoader().uploadQueryFile(t).then((function(n){r.loadFromData(n),e.fireEvent("loadQuery"),e.refreshWidgets(),e.endProcess({result:$.Success,action:q.UploadQueryFile,text:"Uploading query file: "+r.getId()},k.Result),t.success&&t.success()})).catch((function(n){var o="Can't upload a file for query "+r.getId()+".\n "+n.message;e.endProcess({result:$.Error,action:q.UploadQueryFile,text:o,sourceError:n},k.Query),t.error&&t.error(o,"UploadQueryFile")}))},t.prototype.fetchDataChunk=function(t){var e=this,r=this.getQuery().getId(),n=t||{};this.useStoredQueryOnFetch&&(n.queryId=this.query.getId()),this.beforeFetchData&&this.beforeFetchData(this,n),this.startProcess({action:q.FetchData,text:"Fetching data for the query: "+r},k.Result),this.eqServices.getDataFetcher().fetchData(n).then((function(t){t.statement&&(e.resultStatement=t.statement),e.resultContent=t,n.success&&n.success(t),e.fireEvent("fetchData"),e.endProcess({result:$.Success,action:q.FetchData,text:"Data fetching is finished for the query: "+r},k.Result)})).catch((function(t){var o="Data fetching error for the query "+r+". \n"+t.message;e.endProcess({result:$.Error,action:q.FetchData,text:o,sourceError:t},k.Result),n.error&&n.error(o,q.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 "+e.level+" query. \n"+e.message;t.throwError({action:q.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:q.FetchData,text:"DrillDown executing: "+r},k.Result),this.eqServices.getDataFetcher().fetchData(t).then((function(n){e.endProcess({result:$.Success,action:q.FetchData,text:"DrillDown execution error: "+r},k.Result),t.success&&t.success(n)})).catch((function(n){var o="Drill-down data fetching error for query "+r+". \n"+n.message;e.endProcess({result:$.Error,action:q.FetchData,text:o},k.Result),t.error?t.error(o,"DrillDown"):e.throwError({action:q.FetchData,text:o})}))},t.prototype.exportResult=function(t){var e=this;t=t||{},this.beforeExportResult&&this.beforeExportResult(this,t);var r=t.format;if(r){var n=this.getExporter(r);if(n){var o=this.getQuery().getId();this.useStoredQueryOnFetch&&(t.queryId=o),this.startProcess({action:q.ExportResult,text:"Exporting result for query: "+o},k.Result);var i=a.k.getLocaleSettings();t.settings=i;var s=this.query.getAggregationSettings();s.hasAggregates()&&(s.hasGrandTotals()||s.hasGroups())&&(t.aggregates=s.saveToData()),n.export(t).then((function(r){e.fireEvent("exportResult"),e.endProcess({result:$.Success,action:q.ExportResult,text:"The result set for query ["+o+"] has been successfully exported"},k.Result),t.success&&t.success()})).catch((function(r){var n="Error on exporting data for query "+o+". \n"+r.message;e.endProcess({result:$.Error,action:q.ExportResult,text:n,sourceError:r},k.Result),t.error&&t.error(n,"ExportResult")}))}}},t}(),rt=function(){function t(t){this.slot=t,this._id=a.l.generateId(this.getWidgetType())}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!0,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}(),nt=new(function(){function t(t,e,r){this.major=t,this.minor=e,this.update=r}return t.prototype.toString=function(){return this.major+"."+this.minor+"."+this.update},t}())(6,2,0);a.k.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:{},AggreateFunctions:{}})}])}));
|
|
2
2
|
//# sourceMappingURL=easyquery.core.min.js.map
|