@rentman/rm-core 1.5.3 → 1.5.4
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/changelog.md +383 -375
- package/dist/rm-core.js +3 -3
- package/dist/rm-core.min.js +1 -1
- package/dist/src/classes/ItemEntryService.d.ts +2 -2
- package/package.json +1 -1
package/dist/rm-core.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment")):"function"==typeof define&&define.amd?define(["moment"],t):"object"==typeof exports?exports.RmCore=t(require("moment")):e.RmCore=t(e.moment)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0);function o(e,t){for(var r in t)r in e&&void 0!==t[r]&&(e[r]=t[r])}function i(e,t){if(void 0===e)return t;var r={};for(var n in t)r[n]=void 0===e[n]?t[n]:e[n];return r}function s(e){for(var t in e)return!0;return!1}function c(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function a(e,t){for(var r=0,n=t;r<n.length;r++){if(e==n[r])return!0}return!1}function u(e,t){for(var r=[],n=0,o=e;n<o.length;n++){var i=o[n];t(i)&&r.push(i)}if(r.length===e.length)return!1;l(e);for(var s=0,c=r;s<c.length;s++){var a=c[s];e.push(a)}return!0}function l(e){e.splice(0)}function h(e,t){if(void 0===e)return!1;for(var r=0,n=t;r<n.length;r++){var o=n[r];if(void 0===e[o])return!1;e=e[o]}return!0}function p(e,t,r){for(var n=0;n<t.length;n++){var o=t[n];void 0===e[o]&&(e[o]=r[n]),e=e[o]}return e}function f(e,t,r){if(void 0===r&&(r=!1),void 0!==e){for(var n=0,o=t;n<o.length;n++){if(void 0===(e=e[o[n]])&&!r)return}return e}}function d(e,t,r){for(var n=0,o=t.length;n<o;++n){var i=t[n];if(v(i)||F(i))for(var s=Object.keys(i),c=0,a=s.length;c<a;c++){var u=s[c],l=i[u];r&&v(l)?S(l)?e[u]=new Date(l.valueOf()):E(l)?e[u]=new RegExp(l):l.nodeName?e[u]=l.cloneNode(!0):b(l)?e[u]=l.clone():(v(e[u])||(e[u]=R(l)?[]:{}),d(e[u],[l],!0)):e[u]=l}}return e}function m(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return d(e,t,!1)}function y(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return d(e,t,!0)}function v(e){return null!==e&&"object"==typeof e}function g(e){return null!==e&&"object"==typeof e&&!Object.getPrototypeOf(e)}function C(e){return"string"==typeof e}function I(e){return"number"==typeof e}function S(e){return"[object Date]"===toString.call(e)}var R=Array.isArray;function F(e){return"function"==typeof e}function E(e){return"[object RegExp]"===toString.call(e)}function q(e){return"boolean"==typeof e}function b(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function O(e){return e&&e.window===e}function w(e){return void 0!==e}function M(e,t){if(e===t)return!0;if(null===e||null===t)return!1;if(e!=e&&t!=t)return!0;var r,n,o,i,s,c=typeof e;if(c===typeof t&&"object"===c){if(!R(e)){if(S(e))return!!S(t)&&(i=e.getTime(),s=t.getTime(),i===s||i!=i&&s!=s);if(E(e))return!!E(t)&&e.toString()===t.toString();if(O(e)||O(t)||R(t)||S(t)||E(t))return!1;for(n in o=Object.create(null),e)if(!F(e[n])){if(!M(e[n],t[n]))return!1;o[n]=!0}for(n in t)if(!(n in o)&&w(t[n])&&!F(t[n]))return!1;return!0}if(!R(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!M(e[n],t[n]))return!1;return!0}}return!1}function L(e,t,r){var n=[],o=[];if(r=function(e){return I(e)&&e>0}(r)?r:NaN,t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(R(t))t.length=0;else for(var i in t)delete t[i];return n.push(e),o.push(t),s(e,t,r)}return c(e,r);function s(e,t,r){if(--r<0)return"...";if(R(e))for(var n=0,o=e.length;n<o;n++)t.push(c(e[n],r));else if(g(e))for(var i in e)t[i]=c(e[i],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var i in e)e.hasOwnProperty(i)&&(t[i]=c(e[i],r));else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=c(e[i],r));return t}function c(e,t){if(void 0===t&&(t=5),!v(e))return e;var r=n.indexOf(e);if(-1!==r)return o[r];if(O(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var i=!1,a=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(c(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case"[object Boolean]":case"[object Number]":case"[object String]":case"[object Date]":return new e.constructor(e.valueOf());case"[object RegExp]":var r=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return r.lastIndex=e.lastIndex,r;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(F(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===a&&(a=R(e)?[]:Object.create(Object.getPrototypeOf(e)),i=!0),n.push(e),o.push(a),i?s(e,a,t):a}}var T,x=function(){function e(){this.MOMENT_INVALID="Invalid date",this.SERVER_DATETIME_FORMAT="YYYY-MM-DD[T]HH:mm:ssZ",this.SERVER_TIME_FORMAT="HH:mm:ss",this.SERVER_DATE_FORMAT="YYYY-MM-DD"}return e.prototype.formatResponse=function(e,t){for(var r=0,n=t;r<n.length;r++){var o=n[r];e[o.path]=this.formatResponseValue(o.apiColumn.type,e[o.path])}return e},e.prototype.expandResponse=function(e,t,r){for(var n=0,o=r;n<o.length;n++){var i=o[n];e[i.path]=this.formatResponseValue(i.apiColumn.type,t[i.path])}return e},e.prototype.formatRequest=function(e,t,r){for(var n={},o=0,i=r;o<i.length;o++){var s=i[o],c=s.id,a=s.apiColumn,u=a.type;a.readOnly||(this.compareFields(u,e[c],t[c])||(n[c]=this.formatRequestValue(u,t[c])))}return n},e.prototype.formatRequestLocal=function(e,t){for(var r={},n=0,o=t;n<o.length;n++){var i=o[n],s=i.id,c=i.apiColumn;c.readOnly||(r[s]=this.formatRequestValue(c.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r){for(var n=0,o=r;n<o.length;n++){var i=o[n],s=i.id,c=i.apiColumn;if(!c.readOnly&&!this.compareFields(c.type,e[s],t[s]))return!0}return!1},e.prototype.getChanges=function(e,t,r){for(var n=[],o=0,i=r;o<i.length;o++){var s=i[o],c=s.id,a=s.apiColumn;a.readOnly||(this.compareFields(a.type,e[c],t[c])||n.push({oldValue:e[c],newValue:t[c],column:s.apiColumn}))}return n},e.prototype.copyFields=function(e,t,r){for(var n=0,o=r;n<o.length;n++){var i=o[n],s=i.path;t[s]=this.clone(i.apiColumn.type,e[s])}return t},e.prototype.shallowCopyFields=function(e,t,r,n){for(var o=0,i=n;o<i.length;o++){var s=i[o],c=s.path;r[c]=void 0!==e[c]?e[c]:this.clone(s.apiColumn.type,t[c])}return r},e.prototype.setDefaultValues=function(e,t){for(var r=0,n=t;r<n.length;r++){var o=n[r];e[o.id]=this.getDefaultValue(o.apiColumn.type)}return e},e.prototype.compareFields=function(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return M(t,r)}},e.prototype.compareFloats=function(e,t){var r=Math.abs(e),n=Math.abs(t),o=Math.abs(e-t);return e===t||(0===e||0===t||o<Number.MIN_VALUE?o<1.19e-7*Number.MIN_VALUE:o/Math.min(r+n,Number.MAX_VALUE)<1.19e-7)},e.prototype.compareMomentObjects=function(e,t){return e.isValid()?!!t.isValid()&&e.isSame(t):!t.isValid()},e.prototype.compareDurations=function(e,t){return e.asMilliseconds()===t.asMilliseconds()},e.prototype.formatResponseValue=function(e,t){switch(e){case"datetime":case"date":return this.formatResponseDate(t);case"color":return this.formatResponseColor(t);case"duration":return this.formatResponseDuration(t);case"json":return"string"==typeof t&&""!==t?JSON.parse(t):t;case"number":return 0===t?null:t;case"filesize":return t/1e6;default:return t}},e.prototype.formatRequestValue=function(e,t){switch(e){case"datetime":return this.formatRequestDateTime(t);case"date":return this.formatRequestDate(t);case"color":return this.formatRequestColor(t);case"duration":return this.formatRequestDuration(t);case"number":return 0===t?null:t;default:return t}},e.prototype.formatResponseDate=function(e){return null===e?n.invalid():n(e)},e.prototype.formatResponseDuration=function(e){return n.duration(null===e?0:e,"seconds")},e.prototype.formatResponseColor=function(e){return"#"===e.charAt(0)?e:"#"+e},e.prototype.formatRequestDateTime=function(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null},e.prototype.formatRequestDate=function(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null},e.prototype.formatRequestDuration=function(e){return e.asSeconds()},e.prototype.formatRequestColor=function(e){return"#"===e.charAt(0)?e.substring(1):e},e.prototype.getDefaultValue=function(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return n.invalid();case"duration":return n.duration();case"text":case"longtext":return"";case"color":return"#000000";default:return""}},e.prototype.isDefaultValue=function(e,t){return this.compareFields(e,t,this.getDefaultValue(e))},e.prototype.clone=function(e,t){switch(e){case"duration":return this.cloneDuration(t);case"date":case"datetime":return n(t);case"json":return L(t);default:return t}},e.prototype.getCloneFunction=function(e){switch(e){case"duration":return this.cloneDuration;case"date":case"datetime":return this.cloneDate;default:return this.identity}},e.prototype.cloneDuration=function(e){return n.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),j=function(){function e(e,t){this.externalApiRequestService=e,this.apiResponseProcessorFactory=t}return e.prototype.template=function(e,t){return this.processResponse(this.externalApiRequestService.template(e,t))},e.prototype.create=function(e,t,r,n,o){return this.processResponse(this.externalApiRequestService.create(e,t,r,n,o))},e.prototype.delete=function(e,t){return this.processResponse(this.externalApiRequestService.delete(e,t))},e.prototype.updateItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.updateItems(e,t,r))},e.prototype.requestSkeleton=function(e,t){return this.processResponse(this.externalApiRequestService.requestSkeleton(e,t))},e.prototype.moveItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.moveItems(e,t,r))},e.prototype.columns=function(e,t,r){return this.processResponse(this.externalApiRequestService.columns(e,t,r))},e.prototype.query=function(e,t,r,n){return this.processResponse(this.externalApiRequestService.query(e,t,r,n))},e.prototype.processResponse=function(e){var t=this;return e.then(function(e){return t.apiResponseProcessorFactory.construct(e)})},e}(),k=function(){function e(e,t){this.apiFormatter=e,this.response=t,this.columnIndexMap={},this.columnMap={},this.columns=t.columns,this.items=t.items,this.links=t.links,this.cacheable=t.cacheable,this.map=t.map,this.createColumnMaps()}return e.prototype.createColumnMaps=function(){for(var e in this.columns){this.columnIndexMap[e]={},this.columnMap[e]={};for(var t=0;t<this.columns[e].length;t++){var r=this.columns[e][t];this.columnIndexMap[e][r.id]=t,this.columnMap[e][r.id]=r}}},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t])return this.items[e][t].data[this.columnIndexMap[e][r]]},e.prototype.fetchDerivedObject=function(e,t,r){for(var n={},o=0,i=r;o<i.length;o++){var s=i[o];this.fetchDerivedValues(this.fetchValue(e,t,s.id),s,n)}return n},e.prototype.fetchDerivedValues=function(e,t,r){for(var n=0,o=t.children;n<o.length;n++){var i=o[n],s=void 0;null===e?(s=null,r[i.path]=this.apiFormatter.getDefaultValue(i.apiColumn.type)):(s=this.fetchValue(t.itemType,e,i.id),r[i.path]=s),i.isLeaf||this.fetchDerivedValues(s,i,r)}},e.prototype.fetchObject=function(e,t,r){if((void 0===r&&(r=!1),void 0!==this.items[e])&&void 0!==this.items[e][t]){for(var n=this.items[e][t].data,o={},i=0;i<n.length;i++)o[this.columns[e][i].id]=n[i];if(r){var s=this.items[e][t].links;for(var c in o.__links={},s)o.__links[c]=this.fetchObjectArray(c,r,s[c])}return o}},e.prototype.fetchObjectArray=function(e,t,r){var n=[];if(null===r){for(var o in this.items[e])n.push(this.fetchObject(e,o,t));return n}void 0===r&&(r=this.links[e]);for(var i=0,s=r;i<s.length;i++){o=s[i];n.push(this.fetchObject(e,o,t))}return n},e.prototype.fetchObjectMap=function(e,t,r,n){var o=this.columnIndexMap[e][t],i={},s=[];for(var c in this.items[e]){var a=this.items[e][c].data[o];s.push(a),i[a]=this.fetchObject(e,c,r)}return n?{result:i,keys:s}:i},e.prototype.fetchFieldMap=function(e,t){var r=this.columnIndexMap[e][t],n={};for(var o in this.items[e])n[o]=this.items[e][o].data[r];return n},e.prototype.fetchColumnArray=function(e){for(var t=[],r=0,n=this.columns[e];r<n.length;r++){var o=n[r];t.push(o)}return t},e.prototype.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchColumnsObject=function(){return this.columnMap},e.prototype.createResource=function(e,t){return{object:this.fetchObject(e,t),links:this.items[e][t].links}},e.prototype.hasItems=function(e){for(var t in this.items[e])return!0;return!1},e.prototype.getIdArray=function(e){var t=[];for(var r in this.items[e])t.push(r);return t},e}();!function(e){e.CACHED="cached",e.LOCAL="local",e.PROMISED="promised",e.EXPAND="expand",e.PROMISED_EXPAND="promised-expand",e.EXPAND_LOCAL="expand-local",e.PROMISED_EXPAND_LOCAL="promised-expand-local",e.RESOLVE="resolve",e.RESOLVE_VALUES="resolve-values"}(T||(T={}));var D,A=">",H=function(){function e(e,t,r,n){for(var o in this.promiseService=e,this.itemType=t,this.getItemId=r,this.getPromise=n,this.requestStatus=[T.RESOLVE,T.RESOLVE_VALUES,T.EXPAND,T.PROMISED_EXPAND],this.remoteExpandStatus=[T.EXPAND,T.PROMISED_EXPAND],this.localExpandStatus=[T.EXPAND_LOCAL,T.PROMISED_EXPAND_LOCAL],this.entries={},T)this.entries[T[o]]=[]}return e.prototype.add=function(e){this.entries[e.status].push(e.entry)},e.prototype.hasEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.entries[n].length>0)return!0}return!1},e.prototype.hasRequests=function(){return this.hasEntries(this.requestStatus)},e.prototype.forEachEntry=function(e,t){for(var r=0,n=e;r<n.length;r++)for(var o=n[r],i=0,s=this.entries[o];i<s.length;i++){var c=s[i];t(c,this.getItemId(c))}},e.prototype.reduceEntries=function(e,t,r){for(var n=0,o=e;n<o.length;n++)for(var i=o[n],s=0,c=this.entries[i];s<c.length;s++){var a=c[s];t(a,this.getItemId(a),r)}return r},e.prototype.reduceAllEntries=function(e,t){var r=this.entries;for(var n in r)for(var o=0,i=r[n];o<i.length;o++){var s=i[o];e(s,this.getItemId(s),t)}return t},e.prototype.getPromises=function(){var e=this;return this.promiseService.all(this.reduceEntries([T.PROMISED,T.PROMISED_EXPAND],function(t,r,n){n.push(e.getPromise(t))},[]))},e.prototype.getItemIds=function(e){return this.reduceEntries(e,function(e,t,r){r.push(t)},[])},e.prototype.getRequestIds=function(){return this.getItemIds(this.requestStatus)},e.prototype.getArray=function(e){var t=function(e,t,r){r.push(e)};return void 0===e?this.reduceAllEntries(t,[]):this.reduceEntries(e,t,[])},e.prototype.getMap=function(){return this.reduceAllEntries(function(e,t,r){r[t]=e},{})},e}(),P=function(){function e(e,t,r,n){this.collectionCacheFactory=e,this.keyService=t,this.singleItems=r,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.collections=this.collectionCacheFactory.construct(),this.processSingleItems(),this.processCollections(n),this.postProcess()}return e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e){this.moveArray.push(e)},e.prototype.addDeleteEntry=function(e,t){p(this.deleteMap,[e.itemType,e.itemId],[{},{item:e,parent:t}])},e.prototype.addUpdateEntry=function(e){p(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=e.parent;null===t&&(t=this.getDefaultParent()),p(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])},e.prototype.containsCreateEntry=function(e,t){var r=this.compilation.create;for(var n in r)for(var o in r[n]){var i=r[n][o][e];if(void 0!==i)for(var s in i)if(i[s].itemId===t)return!0}return!1},e.prototype.createDeleteCompilation=function(){var e=this.deleteMap,t=this.compilation.delete;for(var r in e)for(var n in e[r]){var o=e[r][n].item;void 0===t[r]&&(t[r]=[]),t[r].push(o)}},e.prototype.postProcess=function(){for(var e=this.deleteMap,t=0,r=this.moveArray;t<r.length;t++){var n=r[t],o=f(e,[n.itemType,n.itemId]);if(void 0!==o){var i=n.parent,s=i.itemType,c=i.itemId;!this.keyService.isLocalId(c)||this.containsCreateEntry(s,c)?(p(this.compilation.move,[s,c],[{},[]]).push(o),delete e[n.itemType][n.itemId]):n.parent=o.parent}}this.createDeleteCompilation()},e.prototype.processSingleItems=function(){for(var e=0,t=this.singleItems;e<t.length;e++){var r=t[e];r.isLocal()?this.addCreateEntry(r):r.hasChanges()&&this.addUpdateEntry(r)}},e.prototype.processCollections=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.collections.add(n),!n.isDeferred()){var o=void 0,i=void 0;n.isLocal()?(o=n.items,i=[]):n.hasEditResources?(o=n.getAddedItems(),i=n.getRemovedItems()):(o=[],i=[]);for(var s=0,c=o;s<c.length;s++){var a=c[s];a.isLocal()?this.addCreateEntry(a):this.addMoveEntry(a)}for(var u=0,l=i;u<l.length;u++){var h=l[u];this.addDeleteEntry(h,n.parent)}if(n.hasItemEditResources)for(var p=0,f=n.getUpdatedItems();p<f.length;p++){var d=f[p];this.addUpdateEntry(d)}}}},e}(),_=function(){function e(e,t,r,n,o,i,s,c,a,u,l){this.apiFormatter=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.collectionEntryService=n,this.collectionHandler=o,this.columnExpansionFactory=i,this.createRequestFactory=s,this.errorHandler=c,this.itemHandler=a,this.promiseService=u,this.requestColumnExpansionFactory=l}return e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var o=n[r].item,i=o.itemType;void 0===t[i]&&(t[i]=[]),t[i].push(o.itemId)}return t},e.prototype.getMapValue=function(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e,t,r,n,o){for(var i=[],s=0,c=this.createRequestFactory.construct(e.compilation.create,e.collections,t,n).run();s<c.length;s++){var a=c[s];i.push(this.executeCreateRequest(a,r).then(u))}return this.promiseService.all(i).then(function(){return r},this.errorHandler.reject);function u(e){return void 0!==o&&o(r),e}},e.prototype.executeCreateRequest=function(e,t){var r=this;return this.apiRequestService.requestSkeleton(e.request).then(function(n){var o=n.map,i=n.fetchColumnsObject(),s=e.items;for(var c in s){var a=r.columnExpansionFactory.construct(c,e.request.columns[c],i);for(var u in s[c]){var l=s[c][u],h=r.getMapValue(c,u,o);if(void 0!==h){var p=n.fetchObject(c,h),f=a.run(l.columns);l.itemId=h,l.updateFields(p,n.fetchDerivedObject(c,h,l.columns.root)),null!==f&&l.expand(p,n.fetchDerivedObject(c,h,f.difference.root),f),r.itemHandler.entries.add(l)}else console.warn("Create failed!",l)}}for(var c in e.collections.addToCollections(),o)for(var u in void 0===t[c]&&(t[c]={}),o[c])t[c][u]=o[c][u]},this.errorHandler.reject)},e.prototype.executeUpdateRequests=function(e,t){var r=[];for(var n in e)r.push(this.executeUpdateRequest(n,e[n],t));return this.promiseService.all(r)},e.prototype.executeUpdateRequest=function(e,t,r){var n=this,o={},i=this.requestColumnExpansionFactory.construct(),s=this.collectionHandler.getCollectionMatcher();for(var c in o[e]={},t){var a=t[c],u=o[e][c]={},l=f(r,[e,c]);u.values=a.formatRequest(),void 0!==l&&(u.parameters=l),i.expand(a.columns),s.expand(a)}for(var h=0,p=s.getCollectionsWithFittingItems();h<p.length;h++){var d=p[h];i.expand(d.columns)}return this.apiRequestService.updateItems(e,o,i.get()).then(function(r){var o=n.columnExpansionFactory.construct(e,i.get()[e],r.fetchColumnsObject());for(var c in t){var a=t[c],u=r.fetchObject(e,c);if(void 0!==u){var l=n.apiFormatter.copyFields(a.initial,{},a.columns.main);a.updateFields(u,r.fetchDerivedObject(e,c,a.columns.root)).callOnChange(l);var h=o.run(a.columns);null!==h&&a.expand(u,r.fetchDerivedObject(e,c,h.difference.root),h)}else console.warn("Update failed!",a)}s.removeFromAndAddToCollections()},this.errorHandler.reject)},e.prototype.executeDeleteRequests=function(e){var t=[];for(var r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeDeleteRequest=function(e,t){for(var r=this,n=[],o=0,i=t;o<i.length;o++){var s=i[o];n.push(s.itemId)}return this.apiRequestService.delete(e,n).then(function(e){for(var n=e.items,o=r.collectionHandler.getCollectionMatcher(),i=0,s=t;i<s.length;i++){var c=s[i];a(c.itemId,n)||console.warn("Delete failed!",c),o.expand(c)}o.removeFromCollections()},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e,t){var r=this,n=[];for(var o in e)for(var i in e[o])s(o,+i);return this.promiseService.all(n);function s(o,i){var s=e[o][i],c=r.getMapValue(o,i,t);n.push(r.apiRequestService.moveItems(o,void 0!==c?c:i,r.buildMoveRequest(s)).then(function(){r.processMoveResponse(s)},r.errorHandler.reject))}},e.prototype.processMoveResponse=function(e){for(var t=[],r={},n={},o=0,i=e;o<i.length;o++){var s=i[o],c=s.item;this.addCollectionMapEntry(r,s.parent.itemId,c,c.itemId),this.addCollectionMapEntry(n,c.parent.itemId,c,c),t.push(c)}this.forEachCollection(r,"removeItems"),this.forEachCollection(n,"addItems")},e.prototype.addCollectionMapEntry=function(e,t,r,n){p(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(n)},e.prototype.forEachCollection=function(e,t){for(var r in e)for(var n in e[r])for(var o in e[r][n]){var i=this.collectionHandler.entries.getByParent(r,n,o);null!==i&&i[t](e[r][n][o],null,!0)}},e.prototype.onItemsCreated=function(e,t,r){if(s(e)){for(var n=0,o=r;n<o.length;n++){var i=o[n],c=i.parent,a=i.getUpdatedItemColumns(e);if(null!==c)void 0!==(d=this.getMapValue(c.itemType,c.itemId,e))&&(c.itemId=d,i.query=this.collectionEntryService.createQuery(i.options),this.collectionHandler.entries.add(i));if(s(a)){void 0!==a.id&&i.onItemsCreated(e[i.itemType]);for(var u=0,l=i.items;u<l.length;u++){(f=l[u]).updateItemFields(e)}}}for(var h=0,p=t;h<p.length;h++){var f,d,m=(f=p[h]).parent;if(f.updateItemFields(e),null!==m)void 0!==(d=this.getMapValue(m.itemType,m.itemId,e))&&(m.itemId=d)}}},e.prototype.execute=function(e,t,r,n,o){var i=this;void 0===r&&(r={});var s=this.errorHandler,c=this.changesCompilationFactory.construct(e,t),a=c.compilation,u={};return this.executeCreateRequests(c,r,u,n,o).then(function(){return i.onItemsCreated(u,e,t),i.executeMoveRequests(a.move,u)},function(r){return i.onItemsCreated(u,e,t),s.reject(r)}).then(function(){return i.executeUpdateRequests(a.update,r)},s.reject).then(function(){return i.executeDeleteRequests(a.delete)},s.reject).then(function(){return u},s.reject)},e}();!function(e){e.MAYBE="maybe"}(D||(D={}));var V,B,N=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.contains=function(e){var t=this.entries[e.itemType];return void 0!==t&&void 0!==t[e.id]},e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.id]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):!!this.contains(e)&&delete this.entries[e.itemType][e.id]},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.matchParent=function(e,t,r){var n=e.parent;return null!==n&&(n.itemType===t&&n.itemId==r)},e.prototype.getByParent=function(e,t,r){var n=this.entries[r];if(void 0===n)return null;for(var o in n)if(this.matchParent(n[o],e,t))return n[o];return null},e.prototype.getResourceByParent=function(e,t,r){var n=this.getByParent(e,t,r);return null===n?null:n.getCurrentResource()},e.prototype.getCollectionsByParent=function(e,t){var r=this.entries,n=[];for(var o in r)for(var i in r[o]){var s=r[o][i];this.matchParent(s,e,t)&&n.push(s)}return n},e.prototype.getByContainingItem=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];void 0!==i.getItemById(t)&&n.push(i)}return n},e.prototype.getByFittingItem=function(e,t,r){var n=this.entries[e],o={fitting:[],notfitting:[],maybe:[]};if(void 0===n)return o;var i=this.queryMatcherFactory.construct(e,t,r);for(var s in n){var c=n[s],a=i.matchQuery(c.query.object);!0===a?o.fitting.push(c):a===D.MAYBE?o.maybe.push(c):o.notfitting.push(c)}return o},e.prototype.getByQuery=function(e,t){var r=this.entries[e];if(void 0===r)return null;for(var n in r){var o=r[n];if(o.query.string===t.string)return o}return null},e.prototype.getByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];i.options.entryKey===t&&n.push(i)}return n},e.prototype.getResourceByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r)for(var i=0,s=r[o].resources;i<s.length;i++){var c=s[i];c.options.resourceKey===t&&n.push(c)}return n},e}(),U=(V=function(e,t){return(V=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}V(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),Q=function(){return function(){this.columns=!0,this.parent=null,this.templateOptions={},this.templateColumns={},this.deferRequest=!1,this.isDuplicate=!1}}(),Y=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return U(t,e),t}(Q),X=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),J=function(){return function(){this.edit=!1,this.onChange=yt,this.onDeactivate=yt}}(),W=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return X(t,e),t}(J),K=0,z=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++K,this.reloadQueued=!1,this.deferRequest=!1,this.parent=null,this.resources=[]}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},e.prototype.defer=function(e){return void 0===e&&(e=!1),this.deferred=this.factory.promiseService.defer(),this.deferRequest=e,this},e.prototype.resolve=function(){var e=this.deferred;return delete this.deferred,delete this.deferRequest,e.resolve(this),this},e.prototype.resolveDeferred=function(e,t,r){return this.columns=r,this.setFields(e,t),this.resolve()},e.prototype.isDeferred=function(){return void 0!==this.deferred},e.prototype.reject=function(e){return void 0===e&&(e=this.factory.itemEntryService.createUnfoundRemoteItemError()),this.deferred.reject(e),delete this.deferred,delete this.deferRequest,this},e.prototype.setFields=function(e,t){var r=this.factory.apiFormatter,n=this.columns.formatted;return this.initial=r.formatResponse(e,n.main),this.derived=r.formatResponse(t,n.derived),this},e.prototype.setLocalFields=function(e,t,r){void 0===r&&(r=this.columns);for(var n=this.factory,o=n.itemEntryService.getLocalDefaultValues(),i=0,s=r.main;i<s.length;i++){var c=s[i].id;o[c]=e[c]}return this.initial=n.apiFormatter.formatResponse(o,r.formatted.main),this.derived={"creator>displayname":n.authInterface.getUserDisplayname()},this.updateItemFields(t)},e.prototype.clone=function(e){void 0===e&&(e={});var t=this.factory,r=t.apiFormatter,n=t.itemEntryService,o=this.columns,i=this.parent,s=n.expandConversionMap(this,e),c=t.construct(s,r.copyFields(this.getFields(),{},o.main),r.copyFields(this.derived,{},o.derived),o);if(c.updateItemFields(e),c.modified=r.copyFields(c.initial,{},o.main),null===i)return c;var a=n.getConversionValue(this.itemType,i.itemId,e);return c.setParent(i.itemType,void 0===a?i.itemId:a),c},e.prototype.resetDerived=function(e){for(var t=this,r=[],n=0,o=this.columns.root;n<o.length;n++){var i=o[n];-1!==e.indexOf(i.id)&&r.push(i)}return function e(r){for(var n=0,o=r;n<o.length;n++){var i=o[n];i.isLeaf||e(i.children),delete t.derived[i.path]}}(r),this},e.prototype.clearResources=function(){return this.resources=[],this},e.prototype.deactivateResources=function(){for(var e=0,t=this.resources;e<t.length;e++){t[e].deactivate()}return this},e.prototype.getFields=function(){return void 0!==this.modified?this.modified:this.initial},e.prototype.expand=function(e,t,r){var n=this.factory.apiFormatter,o=r.difference;return this.columns=r.merged,n.expandResponse(this.initial,e,o.main),n.expandResponse(this.derived,t,o.derived),void 0===this.modified?this:(n.expandResponse(this.modified,e,o.main),this)},e.prototype.expandLocal=function(e){var t=e.difference.main;return this.columns=e.merged,0===t.length?this:(this.setLocalValues(this.initial,t),void 0===this.modified?this:(this.setLocalValues(this.modified,t),this))},e.prototype.setLocalValues=function(e,t){for(var r=this.factory,n=this.parent,o=0,i=t;o<i.length;o++){var s=i[o],c=s.id;if(void 0===e[c]){var a=s.apiColumn.type;e[c]="link"===a&&null!==n?n.itemId:r.apiFormatter.getDefaultValue(a)}}},e.prototype.updateFields=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=!0);var n=this.factory.apiFormatter,o=this.columns.main,i=this.initial,s=this.modified;if(void 0!==s)for(var c=0,a=o;c<a.length;c++){var u=(f=a[c]).id,l=f.apiColumn.type;(r||n.compareFields(l,i[u],s[u]))&&(s[u]=n.formatResponseValue(l,e[u]))}for(var h=0,p=o;h<p.length;h++){var f;i[u=(f=p[h]).id]=n.formatResponseValue(f.apiColumn.type,e[u])}return null!==t&&this.setDerived(t),this},e.prototype.updateItemValues=function(e,t,r){for(var n=this.factory.itemEntryService,o=this.parent,i=0,s=t;i<s.length;i++){var c=s[i],a=c.id,u=c.apiColumn,l=void 0;"link"===u.type&&void 0===e[a]?null!==o&&(l=o.itemId):l=n.getConversionValue(u.itemType,e[a],r),void 0!==l&&(e[a]=l)}},e.prototype.updateItemFields=function(e,t){void 0===t&&(t=this.columns);var r=t.item,n=this.modified;return this.updateItemValues(this.initial,r,e),void 0===n?this:(this.updateItemValues(n,r,e),this)},e.prototype.formatRequest=function(){var e=this.factory.apiFormatter,t=this.columns.main;return this.isLocal()?e.formatRequestLocal(this.getFields(),t):void 0===this.modified?{}:e.formatRequest(this.initial,this.modified,t)},e.prototype.setDisplayName=function(){if(void 0===this.modified)return this;var e=this.getDisplayName();return e&&(this.modified.displayname=e),this},e.prototype.getDisplayName=function(){var e=this.factory.itemEntryService,t=this.getFields();switch(this.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:e.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return e.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);case"Reparatie":return this.derived["materiaal>naam"];default:return t[e.getTitleField(this.itemType)]}},e.prototype.getChanges=function(e){return void 0===e&&(e=!1),void 0!==this.modified||e?this.factory.apiFormatter.getChanges(this.initial,e?{}:this.modified,this.columns.main):[]},e.prototype.isLocal=function(){return this.factory.keyService.isLocalId(this.itemId)},e.prototype.isLockable=function(){if(this.isLocal())return!1;switch(this.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}},e.prototype.hasChanges=function(){return void 0!==this.modified&&this.factory.apiFormatter.hasChanges(this.initial,this.modified,this.columns.main)},e.prototype.resetModified=function(){var e=this.columns.main;if(void 0===this.modified)return this;for(var t=0,r=e;t<r.length;t++){var n=r[t];this.modified[n.id]=this.factory.apiFormatter.clone(n.apiColumn.type,this.initial[n.id])}return this},e.prototype.setInitial=function(e,t){void 0===t&&(t=!1);var r,n=this.factory.apiFormatter;for(var o in e)this.initial[o]=e[o];if(void 0===this.modified)return t&&this.callOnChange(n.copyFields(this.initial,{},this.columns.main)),this;for(var o in r=n.copyFields(this.modified,{},this.columns.main),e)this.modified[o]=e[o];return t&&this.callOnChange(r),this},e.prototype.setModified=function(e){var t=this.factory,r=t.apiFormatter,n=this.columns,o=n.response[this.itemType];if(void 0===this.modified){var i=this.resources,s=this.initial,c=this.modified=this.isLocal()?t.itemEntryService.getLocalDefaultValues():{};if(void 0===e)r.copyFields(s,c,n.main);else for(var a in r.shallowCopyFields(e,s,c,n.main),e)void 0===o[a]&&(c[a]=e[a]);for(var u=0,l=i;u<l.length;u++){l[u].fields=c}return this}if(void 0===e)return this;for(var a in e)this.modified[a]=e[a];return this},e.prototype.setDerived=function(e){for(var t in e)this.derived[t]=e[t];return this},e.prototype.setParent=function(e,t){return this.parent={itemType:e,itemId:t},this},e.prototype.callOnChange=function(e){for(var t=0,r=this.resources.length;t<r;t++){var n=this.resources[t];null!==n&&n.options.onChange(n,e)}return this},e.prototype.toJSON=function(){return{id:this.id,parent:this.parent,initial:this.initial,modified:this.modified,derived:this.derived,columns:this.columns}},e}(),G=function(){function e(e,t,r){void 0===r&&(r=!1),this.entry=e,this.options=t,this._isNew=r,this.derived=e.derived,this.columns=e.columns.response[e.columns.itemType],e.resources.push(this)}return e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.clearResource=function(){var e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)},e.prototype.deactivate=function(){this.options.onDeactivate(this.entry)},e.prototype.toJSON=function(){var e=[];for(var t in this.columns)e.push(t);return{columns:e,fields:this.fields,derived:this.derived,entry:this.entry}},e}(),Z=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),$=function(e){function t(t,r,n){var o=e.call(this,t,r,n)||this;return o.fields=void 0===t.modified?t.initial:t.modified,o}return Z(t,e),t}(G),ee=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),te=function(e){function t(t,r,n,o){var i=e.call(this,r,n,o)||this;return i.factory=t,i.localCopies=[],i.transactions=0,r.setModified(),i.fields=r.modified,i}return ee(t,e),t.prototype.isNew=function(){return this._isNew&&0===this.transactions},t.prototype.start=function(){return void 0===this.localCopies&&(this.localCopies=[]),this.localCopies.push(this.copyFields()),this},t.prototype.rollback=function(){var e=this.entry;return this.factory.apiFormatter.copyFields(this.localCopies.pop(),e.modified,e.columns.main),this.isNew()&&0===this.localCopies.length&&this.deactivate(),this},t.prototype.commit=function(e){void 0===e&&(e=!0);var t=this.localCopies.pop();return e&&this.callOnChange(t),this.transactions++,this},t.prototype.getLocalCopy=function(){var e=this.localCopies;return void 0===e?null:0===e.length?null:e[e.length-1]},t.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(t.modified,e,t.columns.main)},t.prototype.setFields=function(e,t){void 0===t&&(t=!0);var r,n=this.columns,o=this.fields,i=!1;for(var s in t&&(r=this.copyFields()),e){var c=n[s];void 0!==c?this.factory.apiFormatter.compareFields(c.type,o[s],e[s])||(o[s]=e[s],i=!0):console.warn("setFields: no column found for",s)}return t&&i&&this.callOnChange(r),this},t.prototype.callOnChange=function(e){return this.entry.callOnChange(e),this},t.prototype.save=function(e){var t=this,r=this.factory,n=this.entry,o={};return void 0!==e&&p(o,[n.itemType,n.itemId],[{},e]),(n.isLockable()?r.lockService.fetchLock(n):r.promiseService.when()).then(function(){return r.changesProcessor.execute([n],[],o)},r.errorHandler.reject).then(function(){return t},r.errorHandler.reject)},t}(G),re=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ne=function(){return function(){this.columns=[],this.query=null,this.queryParams={},this.parent=null,this.deferRequest=!1,this.limit=null,this.entryKey=null}}(),oe=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return re(t,e),t}(ne),ie=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),se=function(){return function(){this.editItems=!1,this.editCollection=!1,this.modInstant=!1,this.enableSave=!0,this.onItemsCreated=yt,this.onChange=yt,this.onAdd=yt,this.onRemove=yt,this.onAddInitial=yt,this.onRemoveInitial=yt,this.resourceKey=null,this.clearOnTabChange=!0,this.clearOnSubTabChange=!0,this.custom=null}}(),ce=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return ie(t,e),t}(se),ae=0,ue=function(){function e(e,t,r){this.factory=e,this.itemType=t,this.options=r,this.id=ae++,this.templateColumns=null,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.reloadQueued=!1,this.hasEditResources=!1,this.hasItemEditResources=!1,this.parent=r.parent,this.query=e.collectionEntryService.createQuery(r),this.columns=e.columnSetFactory.constructStub(t,r.columns),this.defer()}return e.prototype.defer=function(){return this.isDeferred()?this:(this.deferred=this.factory.promiseService.defer(),this.promise=this.deferred.promise,this)},e.prototype.isDeferred=function(){return void 0!==this.promise},e.prototype._resolve=function(){var e=this.deferred;return delete this.deferred,delete this.promise,e.resolve(this),this},e.prototype.resolve=function(e){var t=e.initial,r=e.modified;return this.columns=e.columns,this.initial=t,this.items=void 0!==r?r:t.slice(),this._resolve()},e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.factory.keyService.isLocalId(e.itemId)},e.prototype.matchParent=function(e,t){var r=this.parent;return null!==r&&(r.itemType===e&&r.itemId==t)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.getItemById=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(n.itemId===e)return n}},e.prototype.getIdArray=function(e){return void 0===e&&(e=[]),this.factory.collectionEntryService.getIdArray(this.items,e)},e.prototype.createItems=function(e){var t,r=this,n=this.factory,o=this.columns;return n.itemHandler.fetchTemplate(this.itemType).then(function(i){t=i;var s=[];null===r.templateColumns&&(r.templateColumns=t.columns.merge(o));for(var c=0,a=e;c<a.length;c++){var u=a[c];s.push(n.itemEntryFactory.constructLocal(n.keyService.getLocalId(),t,u,{},r.parent,r.templateColumns))}return s},n.errorHandler.reject)},e.prototype.resolveDerivedValues=function(e,t){return this.factory.itemHandler.resolveDerivedValues(e,this.columns.root,t)},e.prototype.addItems=function(e,t,r,n,o){if(void 0===r&&(r=!1),0===e.length)return[];var i=this.items,s=this.parent,c=this.columns.link,a=[],u=[];if(r)for(var l=this.initial,h=0,p=e;h<p.length;h++){var f=p[h];-1===l.indexOf(f)&&(l.push(f),a.push(f))}for(var d=0,m=e;d<m.length;d++){f=m[d];-1===i.indexOf(f)&&(null!==s&&(f.parent=s,null!==c&&void 0!==f.modified&&(f.modified[c.id]=s.itemId)),i.push(f),u.push(f))}return this.handleAddedItemCallbacks(a,u,t,n,o)},e.prototype.handleAddedItemCallbacks=function(e,t,r,n,o){void 0===r&&(r=null),void 0===n&&(n=!0),void 0===o&&(o=!0);var i=this.resources;if(e.length>0)for(var s=0,c=i;s<c.length;s++){(m=c[s]).options.onAddInitial(e,this)}if(0===t.length)return null===r?null:[];if(o&&i.length>0)for(var a=i[0].localCache,u=0,l=t;u<l.length;u++){var h=l[u];a.onActivateItem(h)}for(var p=null,f=0,d=i;f<d.length;f++){var m,y=(m=d[f]).addItemResources(t);m===r?(p=y,n&&m.callOnAdd(y)):m.callOnAdd(y)}return p},e.prototype.removeItems=function(e,t,r,n){return 0===e.length?[]:this.handleRemovedItems(function(t){return!a(t.itemId,e)},t,r,n)},e.prototype.clear=function(e,t,r){return this.handleRemovedItems(function(){return!1},e,t,r)},e.prototype.handleRemovedItems=function(e,t,r,n){void 0===r&&(r=!1);var o,i=this.factory.collectionEntryService,s=i.filterArray(this.items,e);if(r)o=i.filterArray(this.initial,e);else{for(var c=[],a=0,u=s;a<u.length;a++){var l=u[a];l.isLocal()&&c.push(l)}o=c.length>0?i.filterArray(this.initial,function(e){return-1===c.indexOf(e)}):[]}return this.handleRemovedItemCallbacks(o,s,t,n)},e.prototype.handleRemovedItemCallbacks=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=this.resources;if(e.length>0)for(var i=0,s=o;i<s.length;i++){(p=s[i]).options.onRemoveInitial(e,this)}if(0===t.length)return null===r?null:[];for(var c=null,a=0,u=t;a<u.length;a++){u[a].deactivateResources()}for(var l=0,h=o;l<h.length;l++){var p,f=(p=h[l]).removeItemResources(t);p===r?(c=f,n&&p.callOnRemove(f)):p.callOnRemove(f)}return c},e.prototype.createBatchStatus=function(e,t,r){return this.factory.itemHandler.createBatchStatus(this.itemType,e,this.parent,t,!1,r,!1).batchStatus},e.prototype.expandLocal=function(e,t){var r=this,n=this.factory,o=n.errorHandler,i=this.itemType;return n.columnHandler.fetch(i,e).then(function(s){var c=n.columnExpansionFactory.construct(i,e,s),a=r.createBatchStatus(r.getIdArray(),e,t);return a.getPromises().then(function(){return n.itemHandler.handleBatchResponse(a,t,e,null,s,c)},o.reject).then(function(){return c},o.reject)},o.reject)},e.prototype.expandRemote=function(e,t){var r=this,n=this.factory,o=n.errorHandler,i=this.itemType;return n.itemRequestService.requestItems(this,void 0,e).then(function(s){var c=s.items[i],a=s.fetchColumnsObject();r.handleRemovedItems(function(e){return void 0!==c[e.itemId]||e.isLocal()},null,!0,!0);var u=n.columnExpansionFactory.construct(i,e,a),l=r.createBatchStatus(s.links[i],e,t);return l.getPromises().then(function(){return n.itemHandler.handleBatchResponse(l,t,e,s,null,u)},o.reject).then(function(){return u},o.reject)},o.reject)},e.prototype.expand=function(e,t){var r=this;return!0!==e&&0===e.length?this.factory.promiseService.when(this):(this.isLocal()?this.expandLocal(e,t):this.expandRemote(e,t)).then(function(e){return r.expandColumns(e),r})},e.prototype.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.factory.collectionEntryService.createQuery(t))},e.prototype.extend=function(e,t,r,n){var o=this,i=this.factory,s=i.errorHandler,c=this.extendQuery(e).object,a=i.queryService.addAndCondition(c,i.queryService.createNotIn(this.getIdArray())),u=i.itemRequestService.requestItems(this,null!==this.options.limit?c:a).then(function(e){return i.itemRequestService.processResponse(e,e.links[o.itemType],o.parent,o.columns)},s.reject).then(function(e){return delete o.promise,o.addItems(e,t,n,r,!1)},s.reject);return this.promise=u.then(function(){return o},s.reject),u},e.prototype.queueReload=function(){this.reloadQueued=!0},e.prototype.expandColumns=function(e){var t=e.run(this.columns);null!==t&&(this.columns=t.merged,this.templateColumns=null,this.options.columns=this.columns.request)},e.prototype.expandRequestColumns=function(e){this.columns.expandRequestColumns(e),this.options.columns=this.columns.request},e.prototype.getAddedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=[],n=0,o=this.items;n<o.length;n++){var i=o[n];-1===t.indexOf(i)&&r.push(e?i.itemId:i)}return r},e.prototype.getRemovedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=this.items,n=[],o=0,i=t;o<i.length;o++){var s=i[o];-1===r.indexOf(s)&&n.push(e?s.itemId:s)}return n},e.prototype.getUpdatedItems=function(){for(var e=[],t=0,r=this.items;t<r.length;t++){var n=r[t];!n.isLocal()&&n.hasChanges()&&e.push(n)}return e},e.prototype.hasAddedItems=function(){return this.items.length>this.initial.length},e.prototype.hasRemovedItems=function(){return this.initial.length>this.items.length},e.prototype.hasUpdatedItems=function(){for(var e=0,t=this.items;e<t.length;e++){if(t[e].hasChanges())return!0}return!1},e.prototype.getCurrentResource=function(){var e=this.resources;return e[e.length-1]},e.prototype.clearResources=function(e){void 0===e&&(e=!1);for(var t=this.items,r=this.resources,n=[],o=0,i=t;o<i.length;o++){i[o].clearResources()}for(var s=0,c=r;s<c.length;s++){var a=c[s];if(!a.options[e?"clearOnSubTabChange":"clearOnTabChange"]){n.push(a);for(var u=0,l=a.items;u<l.length;u++){var h=l[u];h.entry.resources.push(h)}}}this.resources=n},e.prototype.revertChanges=function(){var e=this.getAddedItems(),t=this.getRemovedItems();this.items=this.initial.slice(),this.handleAddedItemCallbacks([],t),this.handleRemovedItemCallbacks([],e)},e.prototype.onItemsCreated=function(e){for(var t=0,r=this.resources;t<r.length;t++){var n=r[t];n.rebuildMap(),n.options.onItemsCreated(e)}},e.prototype.getUpdatedItemColumns=function(e){for(var t={},r=0,n=this.columns.item;r<n.length;r++){var o=n[r];void 0!==e[o.apiColumn.itemType]&&(t[o.id]=o)}return t},e.prototype.clone=function(e,t){for(var r=this.factory,n=r.itemEntryService.batchClone(this.items,t),o=0,i=n;o<i.length;o++){i[o].parent=e}return r.construct(this.itemType,r.collectionEntryService.cloneOptions(this.options,e)).resolve({columns:this.columns,initial:n})},e}(),le=function(){function e(e,t,r,n){this.itemResourceFactory=e,this.entry=t,this.options=r,this.localCache=n,this.itemIdMap={},this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}return e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.rebuildMap=function(){for(var e={},t=0,r=this.items;t<r.length;t++){var n=r[t];e[n.entry.itemId]=n}this.itemIdMap=e},e.prototype.addItemResources=function(e){var t=this;if(0===e.length)return[];for(var r=[],n=this.options,o=this.items,i=this.itemIdMap,s=this.itemResourceFactory.getConstructor({edit:n.editItems,onChange:n.onChange,onDeactivate:function(e){return t.localCache.onDeactivateItem(e)}}),c=0,a=e;c<a.length;c++){var u=a[c],l=u.itemId,h=void 0;void 0===i[l]?(h=s(u),o.push(h),i[l]=h):h=i[l],r.push(h)}return r},e.prototype.removeItemResources=function(e){var t=this,r=[];return u(this.items,function(n){for(var o=0,i=e;o<i.length;o++){var s=i[o];if(n.entry===s)return r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e){this.options.onAdd(e,this)},e.prototype.callOnRemove=function(e){this.options.onRemove(e,this)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.filter=function(e){for(var t=[],r=0,n=this.items;r<n.length;r++){var o=n[r];e(o)&&t.push(o)}return t},e.prototype.first=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(e(n))return n}return null},e.prototype.some=function(e){return null!==this.first(e)},e.prototype.groupBy=function(e){var t=this.items,r={};if("string"==typeof e)for(var n=0,o=t;n<o.length;n++){void 0===r[a=(c=o[n]).fields[e]]&&(r[a]=[]),r[a].push(c)}if("function"==typeof e)for(var i=0,s=t;i<s.length;i++){var c,a;null!==(a=e(c=s[i]))&&(void 0===r[a]&&(r[a]=[]),r[a].push(c))}return r},e.prototype.map=function(e){var t=this.items,r=t.length,n=new Array(r);if("string"==typeof e)for(var o=0;o<r;o++)n[o]=t[o].fields[e];if("function"==typeof e)for(o=0;o<r;o++)n[o]=e(t[o]);return n},e.prototype.reduce=function(e,t){for(var r=0,n=this.items;r<n.length;r++){t=e(n[r],t)}return t},e.prototype.extend=function(e,t,r){var n=this;return void 0===t&&(t=!1),this.entry.extend(e,this,r,!0).then(function(e){return t?n.items:e})},e.prototype.deactivate=function(){this.localCache.clearCollection(this)},e.prototype.clearResource=function(){var e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(var n=0,o=t;n<o.length;n++){o[n].clearResource()}},e}(),he=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),pe=function(e){function t(t,r,n,o){return e.call(this,t,r,n,o)||this}return he(t,e),t}(le),fe=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),de=function(e){function t(t,r,n,o){var i=e.call(this,t.itemResourceFactory,r,n,o)||this;return i.factory=t,i}return fe(t,e),t.prototype.save=function(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");var e=this.factory,t=this.entry,r=t.parent;return null!==r&&e.keyService.isLocalId(r.itemId)?e.promiseService.when():e.changesProcessorFactory.construct().execute([],[t])},t.prototype.moveItems=function(e,t,r){var n=this.entry,o=this.options;if(o.enableSave||o.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(n.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var i=n.removeItems(e,this,!1,r),s=[],c=0,a=i;c<a.length;c++){var u=a[c];s.push(u.entry)}return t.entry.addItems(s,t,!1,r),i},t.prototype.removeItems=function(e,t){var r=this;void 0===t&&(t=!0);var n=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(function(){return t&&r.callOnRemove(n),n}):(t&&this.callOnRemove(n),this.factory.promiseService.when(n))},t.prototype.removeItem=function(e,t){return this.removeItems([e],t).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.addItems=function(e,t,r){var n=this;void 0===t&&(t=!0);var o=this.factory,i=this.options.modInstant;return this.entry.createItems(e).then(function(e){return i?e:n.entry.resolveDerivedValues(e,n.localCache.items)}).then(function(e){var s=n.entry.addItems(e,n,!1,!1,r);return i?n.save().then(function(){return t&&n.callOnAdd(s),s},o.errorHandler.reject):(t&&n.callOnAdd(s),s)},o.errorHandler.reject)},t.prototype.addItem=function(e,t,r){return this.addItems([e],t,r).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.clear=function(e){return this.entry.clear(this,!1,e)},t}(le),me=function(){return function(e,t,r,n){this.itemType=t,this.response=r,this.fields=r.fetchObject(t,r.links[t][0]),this.responseColumns=e.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),n).merged,this.columns=e.columnSetFactory.construct(t,!0,this.responseColumns)}}(),ye=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.cloneOptions=function(e,t){var r=new oe(e);return r.queryParams=this.cloneQueryParams(e.queryParams),r.parent=t,r},e.prototype.processOptions=function(e){return new oe(e)},e.prototype.cloneQueryParams=function(e){var t={};for(var r in e){var o=e[r],i=void 0;i=Array.isArray(o)?o.slice():n.isMoment(o)?o.clone():o,t[r]=i}return t},e.prototype.createQuery=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:"&parentId"}};e.queryParams.parentId=r.itemId,t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}var o=this.queryParserFactory.construct(t,e.queryParams).parse();return{object:o[0],string:o[1]}},e.prototype.getIdArray=function(e,t){void 0===t&&(t=[]);for(var r=0,n=e;r<n.length;r++){var o=n[r];t.push(o.itemId)}return t},e.prototype.filterArray=function(e,t){for(var r=[],n=[],o=0,i=e;o<i.length;o++){var s=i[o];(t(s)?r:n).push(s)}if(0===n.length)return n;e.length=r.length;for(var c=0;c<e.length;c++)e[c]=r[c];return n},e}(),ve=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h,p,f){this.batchStatusFactory=e,this.collectionCacheFactory=t,this.collectionEntryFactory=r,this.collectionEntryService=n,this.collectionMatcherFactory=o,this.columnHandler=i,this.columnSetFactory=s,this.errorHandler=c,this.itemHandler=a,this.itemRequestService=u,this.keyService=l,this.promiseService=h,this.queryParserFactory=p,this.queryService=f,this.entries=this.collectionCacheFactory.construct()}return e.prototype.removeFromAndAddToCollections=function(e,t){for(var r in e){var n=e[r],o=n.collection;o.removeItems(n.notfitting,null,!0),o.addItems(n.fitting,null,!0),n.maybe.length>0&&o.extend(vt,null,!0,t)}},e.prototype.getCollectionMatcher=function(){return this.collectionMatcherFactory.construct([this.entries],!0,!0)},e.prototype.removeFromCollections=function(e,t,r){var n;for(var o in void 0===r&&(r=null),e){for(var i=e[o],s=i.fitting,c=i.maybe,a=i.collection,u=[],l=0,h=s;l<h.length;l++){var p=h[l];u.push(p.itemId)}for(var f=0,d=c;f<d.length;f++){var m=d[f];u.push(m)}null!==r&&a===r.entry?n=a.removeItems(u,r,t):a.removeItems(u,null,t)}return n},e.prototype.addToCollections=function(e,t,r){var n;for(var o in void 0===r&&(r=null),e){var i=e[o],s=i.collection;s.isDeferred()||(null!==r&&s===r.entry?n=s.addItems(i.fitting,r,t):s.addItems(i.fitting,null,t),t&&i.maybe.length>0&&s.extend(vt,null,!0,t))}return n},e.prototype.batchExpand=function(e,t,r,n){var o=this;if(0===n.length)return this.promiseService.when(r);var i=[],s=[];for(var c in r){var a=r[c].entry;a.defer(),i.push(a.parent.itemId),s=s.concat(a.items)}return this.itemRequestService.requestLinkItems(e,i,t,null,n).then(function(e){for(var c=o.itemRequestService.processExpansion(n,e,t,s),a=0,u=i;a<u.length;a++){var l=u[a],h=r[l].entry;h.expandColumns(c),h._resolve()}return r})},e.prototype.batchExtend=function(e,t,r,n,o,i){var c=this;if(void 0===i&&(i=!1),!s(o))return this.promiseService.when({});var a=[],u=[];for(var l in r.queryParams=n(r.queryParams),o){var h=o[l].entry;h.extendQuery(n),a.push(h.parent.itemId),u=u.concat(h.getIdArray())}return this.itemRequestService.requestLinkItems(e,a,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(u)),r.columns).then(function(n){return c.itemRequestService.processLinkResponse(n,e,a,t,r)},this.errorHandler.reject).then(function(e){for(var t={},r=0,n=a;r<n.length;r++){var s=n[r],c=o[s],u=c.entry.addItems(e.items[s],c);t[s]=i?c.items:u}return t},this.errorHandler.reject)},e.prototype.batchFetch=function(e,t,r,n,o,i,s){for(var c=this,a=this.errorHandler,u=this.batchStatusFactory.construct(r,function(e){return e.parent.itemId},function(e){return e.promise}),l=0,h=t;l<h.length;l++){var p=h[l];u.add(this.getEntryStatus(r,this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:p}),i,s))}return this.promiseService.all(u.getPromises()).then(function(){var i,s,l=u.getRequestIds();if(null===n.query)s=null;else{var h=c.queryParserFactory.construct(n.query,n.queryParams).parse();s={object:h[0],string:h[1]}}if(l.length>0)i=c.itemRequestService.requestLinkItems(e,l,r,null===s?null:s.object,n.columns).then(function(t){return c.itemRequestService.processLinkResponse(t,e,l,r,n)},a.reject);else{if(!u.hasEntries([T.LOCAL]))return u.getMap();i=c.columnHandler.fetch(r,n.columns).then(function(e){return{columns:c.columnSetFactory.construct(r,n.columns,e,!1)}},a.reject)}return i.then(function(n){var i=o.batchGetLocalByParent(e,t,r,s),l=[];for(var h in i)l=l.concat(i[h]);return c.expandLocalItemEntries(r,l,n.columns,o).then(function(){return c.handleBatchResponse(u,n,i)},a.reject)},a.reject)},a.reject)},e.prototype.handleBatchResponse=function(e,t,r){var n={};return e.forEachEntry([T.CACHED],function(e,t){n[t]=e}),e.forEachEntry([T.RESOLVE],function(e,o){var i=t.items[o];n[o]=e.resolve({initial:i,modified:i.concat(r[o]),columns:t.columns})}),e.forEachEntry(e.remoteExpandStatus,function(e,r){e.expandColumns(t.columnExpansion),n[r]=e._resolve()}),e.forEachEntry([T.LOCAL],function(e,o){n[o]=e.resolve({initial:r[o],columns:t.columns})}),n},e.prototype.fetch=function(e,t,r,n,o){var i=this.errorHandler,s=this.getEntryStatus(e,t,n,o),c=s.entry;switch(s.status){case T.CACHED:return this.promiseService.when(c);case T.PROMISED:return c.promise;case T.EXPAND:return c.expand(t.columns,r).then(function(){return c._resolve()},i.reject);case T.PROMISED_EXPAND:return c.promise.then(function(){return c.defer().expand(t.columns,r)},i.reject).then(function(){return c._resolve()},i.reject);case T.LOCAL:return this.resolveLocal(c,r);default:return this.resolveRemote(c,r)}},e.prototype.getCachedEntryStatus=function(e,t){return e.columns.isSupersetOf(t.columns)?e.isDeferred()?T.PROMISED:e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?T.CACHED:(e.defer(),T.RESOLVE)):T.CACHED:e.isDeferred()?T.PROMISED_EXPAND:(e.defer(),T.EXPAND)},e.prototype.getDeferredEntryStatus=function(e,t,r,n){var o;return t.deferRequest?null!==(o=n.getByQuery(e,r))?(o.expandRequestColumns(t.columns),{entry:o,isDeferred:!1}):(o=this.collectionEntryFactory.construct(e,t),{entry:n.add(o),isDeferred:!0}):{entry:o=this.collectionEntryFactory.construct(e,t),isDeferred:!1}},e.prototype.getEntryStatus=function(e,t,r,n){var o,i,s,c=this.collectionEntryService.createQuery(t);return this.isLocal(t)?null!==(s=r.getByQuery(e,c))?{entry:s,status:this.getCachedEntryStatus(s,t)}:(s=(o=this.getDeferredEntryStatus(e,t,c,n)).entry,o.isDeferred?{entry:s,status:T.PROMISED}:{entry:r.add(s),status:T.LOCAL}):null!==(s=this.entries.getByQuery(e,c))?{entry:r.add(s),status:this.getCachedEntryStatus(s,t)}:(s=(i=this.getDeferredEntryStatus(e,t,c,n)).entry,i.isDeferred?{entry:s,status:T.PROMISED}:(r.add(s),this.entries.add(s),{entry:s,status:T.RESOLVE}))},e.prototype.resolveLocal=function(e,t){var r=this,n=e.itemType,o=e.options.columns;return this.columnHandler.fetch(n,o).then(function(i){var s=r.columnSetFactory.construct(n,o,i,!1);return r.expandLocalItemEntries(n,t.getLocalByQuery(n,e.query),s,t).then(function(t){return e.resolve({initial:t,columns:s})},r.errorHandler.reject)},this.errorHandler.reject)},e.prototype.resolveRemote=function(e,t){var r,n=this,o=this.errorHandler,i=e.itemType;return this.itemRequestService.requestItems(e).then(function(t){return r=n.columnSetFactory.construct(i,e.options.columns,t.fetchColumnsObject()),n.itemRequestService.processResponse(t,t.links[i],e.parent,r)},o.reject).then(function(s){return n.expandLocalItemEntries(i,t.getLocalByQuery(i,e.query),r,t).then(function(t){return e.resolve({initial:s,modified:s.concat(t),columns:r})},o.reject)},o.reject)},e.prototype.isLocal=function(e){var t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)},e.prototype.expandLocalItemEntries=function(e,t,r,n){return this.itemHandler.expandLocalEntries(e,t,r.request,r.response,n)},e}(),ge=function(){function e(e,t,r,n){this.queryMatcherFactory=e,this.collectionCaches=t,this.updateInitial=r,this.callOnActivate=n,this.map={}}return e.prototype.expand=function(e){var t=this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent);return this._expand(e,function(e){return t.matchQuery(e.query.object)})},e.prototype._expand=function(e,t){for(var r=this.map,n=e.itemId,o=0,i=this.collectionCaches;o<i.length;o++)for(var s=0,c=i[o].getByItemType(e.itemType);s<c.length;s++){var a=c[s],u=a.id,l=void 0;void 0===r[u]&&(r[u]={collection:a,matches:{}}),void 0===(l=r[u].matches)[n]&&(l[n]={item:e,isMatch:t(a)})}return this},e.prototype.getCollectionsWithFittingItems=function(){var e=[];for(var t in this.map){var r=this.map[t];this.hasFittingItems(r.matches)&&e.push(r.collection)}return e},e.prototype.addToCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],o=n.collection,i=this.groupItemEntries(n.matches),s=i.fitting;o.isDeferred()||(null!==e&&o===e.entry?t=o.addItems(s,e,this.updateInitial,!0,this.callOnActivate):o.addItems(s,null,this.updateInitial,!0,this.callOnActivate),this.updateInitial&&i.maybe.length>0&&o.extend(vt,null,!0,this.updateInitial))}return t},e.prototype.removeFromCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],o=n.collection,i=this.groupItemIds(n.matches).fitting;null===e||o!==e.entry?t=o.removeItems(i,e,this.updateInitial):o.removeItems(i,null,this.updateInitial)}return t},e.prototype.removeFromAndAddToCollections=function(){for(var e in this.map){var t=this.map[e],r=t.collection,n=this.groupItemEntries(t.matches);r.removeItems(n.notFitting,null,this.updateInitial),r.addItems(n.fitting,null,this.updateInitial),n.maybe.length>0&&r.extend(vt,null,!0,this.updateInitial)}},e.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var o in e){var i=e[o],s=i.item,c=i.isMatch;!0===c?t.push(s):!1===c?r.push(s.itemId):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},e.prototype.groupItemIds=function(e){var t=[],r=[];for(var n in e){var o=e[n];(!1===o.isMatch?r:t).push(o.item.itemId)}return{fitting:t,notFitting:r}},e.prototype.hasFittingItems=function(e){for(var t in e)if(!0===e[t].isMatch)return!0;return!1},e}(),Ce=function(){function e(){}return e.prototype.processOptions=function(e){return new ce(e)},e.prototype.getIdArray=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var o=n[r];t.push(o.entry.itemId)}return t},e}(),Ie=function(){function e(e){this.columnUtil=e,this.cache={},this.allColumns={}}return e.prototype.setColumn=function(e,t){var r=this.cache;void 0===r[e]&&(r[e]={});var n=r[e],o=t.id;return void 0===n[o]&&(n[o]=t),n[o]},e.prototype.setColumns=function(e,t,r){var n={};for(var o in r){var i=r[o];for(var s in n[o]={},i)n[o][s]=this.setColumn(o,i[s])}return!0===t&&(this.allColumns[e]=!0),n},e.prototype.retrieve=function(e,t){if(!0===t)return this.containsAll(e)?{cached:this.getColumns(e),missing:[]}:{cached:{},missing:!0};var r={},n=[];return this.retrieveColumns(e,t,n,r),{cached:r,missing:n}},e.prototype.containsAll=function(e){return!0===this.allColumns[e]},e.prototype.getColumns=function(e){var t,r=this.cache;return(t={})[e]=void 0===r[e]?[]:r[e],t},e.prototype.retrieveColumns=function(e,t,r,n){this.retrieveColumn(e,"id",r,n);for(var o=0,i=t;o<i.length;o++){var s=i[o];this.retrieveColumn(e,s,r,n)}},e.prototype.retrieveColumn=function(e,t,r,n){var o,i=this.columnUtil.parseRequestColumn(t),s=this.getColumn(e,i.id);if(void 0!==s){if(void 0===n[e]&&(n[e]={}),n[e][i.id]=s,0!==i.children.length){var c=[];this.retrieveColumns(s.itemType,i.children,c,n),0!==c.length&&r.push(((o={})[i.id]=c,o))}}else r.push(t)},e.prototype.getColumn=function(e,t){var r=this.cache[e];if(void 0!==r)return r[t]},e}(),Se=function(){function e(e,t,r,n){if(this.columnInfoFactory=e,this.itemType=t,this.responseColumns=n,this.expansionMap={},this.expansionMapSize=0,!0===r)for(var o in this.requestColumnsTrue=!0,this.requestColumns=[],n[t])this.requestColumns.push(o);else this.requestColumnsTrue=!1,this.requestColumns=r}return e.prototype.run=function(e){var t=this.expansionMap,r=e.id;return void 0!==t[r]?t[r]:(this.expansionMapSize++,t[r]=e.isSupersetOf(this.requestColumns)?null:e.expand(this.requestColumns,this.requestColumnsTrue,this.responseColumns))},e.prototype.aggregateRootColumns=function(){var e=this.expansionMap;if(1===this.expansionMapSize){var t=e[c(e)];return null!==t?t.difference.root:[]}var r={};for(var n in e){var o=e[n];null!==o&&this.expandRootColumnMap(o.difference.root,r)}return this.processRootColumnMap(r,null)},e.prototype.expandRootColumnMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var o=n[r],i=o.id;void 0===t[i]&&(t[i]={apiColumn:o.apiColumn,children:{}}),this.expandRootColumnMap(o.children,t[i].children)}},e.prototype.processRootColumnMap=function(e,t){var r=[];for(var n in e){var o=e[n],i=this.columnInfoFactory.construct(o.apiColumn,t),s=this.processRootColumnMap(o.children,i);s.length>0&&i.setChildren(i.apiColumn.itemType,s),r.push(i)}return r},e}(),Re=function(){function e(e,t,r,n,o){this.apiRequestService=e,this.errorHandler=t,this.promiseService=r,this.cache=n,this.columnUtil=o}return e.prototype.setColumn=function(e,t){return this.cache.setColumn(e,t)},e.prototype.setColumns=function(e,t,r){return this.cache.setColumns(e,t,r)},e.prototype.fetchItemTypeTranslations=function(e){for(var t={},r=0,n=e;r<n.length;r++){var o=n[r];t[o]=this.fetch(o,["id"])}return this.promiseService.all(t).then(function(e){var t={};for(var r in e)t[r]=e[r][r].id.name;return t},this.errorHandler.reject)},e.prototype.request=function(e,t,r){var n,o=this;return void 0===r&&(r={filter:!1}),this.apiRequestService.columns(e,(n={},n[e]=t,n),r).then(function(r){return o.cache.setColumns(e,t,r.fetchColumnsObject())},this.errorHandler.reject)},e.prototype.fetch=function(e,t,r){var n=this,o=this.cache.retrieve(e,t);return!0!==o.missing&&0===o.missing.length?this.promiseService.when(o.cached):this.request(e,o.missing,r).then(function(e){return n.columnUtil.mergeResponseColumns(e,o.cached).merged})},e.prototype.fetchAll=function(e){return this.cache.containsAll(e)?this.promiseService.when(this.cache.getColumns(e)):this.request(e,!0)},e}(),Fe=function(){function e(e,t){void 0===t&&(t=null),this.apiColumn=e,this.parent=t,this.itemType=null,this.children=[],this.isLeaf=!0;var r=e.id;this.id=r,null===t?(this.level=0,this.path=r,this.tailPath=""):(this.level=t.level+1,this.path=t.path+A+r,this.tailPath=0===t.level?r:t.tailPath+A+r)}return e.prototype.setChildren=function(e,t){return this.itemType=e,this.children=t,this.isLeaf=!1,this},e}(),Ee={},qe=0,be=function(){function e(e,t,r,n,o,i){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r,this.columnSetFactory=n,this.itemType=o,this.request=i,this.id=++qe,this.response=Ee,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.requestColumnsTrue=this.requestColumnsIsTrue(this.request)}return e.prototype.toJSON=function(){var e=function(e){return e.map(function(e){return e.id})};return{main:e(this.main),derived:e(this.derived)}},e.prototype.resolve=function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),this.enableCaching=t,this.requestColumnsTrue?this.processResponseColumns(e):this.processRequestColumns(e,r),this},e.prototype.expandRequestColumns=function(e){var t=this.columnUtil.mergeRequestColumns(this.request,e).merged;this.request=t,this.requestColumnsTrue=!0===t},e.prototype.isSupersetOf=function(e){if(!0===e)return this.requestColumnsTrue;var t=this.columnUtil,r=this.request;if(!0===r)return!t.containsDerivedColumns(e);for(var n=0,o=e;n<o.length;n++){var i=o[n];if(!t.containsColumn(i,r))return!1}return!0},e.prototype.processResponseColumns=function(e){var t=this.itemType;for(var r in this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,e):e,e[t])this.main.push(this.getColumnInfo(r,t,[],null,e)),this.request.push(r)},e.prototype.requestColumnsIsTrue=function(e){return!0===e},e.prototype.processRequestColumns=function(e,t){var r=this.itemType,n=this.request;if(this.response={},!this.requestColumnsIsTrue(n)&&0!==n.length){for(var o=0,i=n;o<i.length;o++){var s=i[o];null!==(c=this.getRequestColumnInfo(s,r,null,e))&&(this.main.push(c),c.isLeaf||this.root.push(c))}var c;if(t&&void 0===this.response[r].id)null!==(c=this.getRequestColumnInfo("id",r,null,e))&&this.main.push(c)}},e.prototype.getRequestColumnInfo=function(e,t,r,n){var o,i=this.columnUtil.parseRequestColumn(e),s=i.id;if(void 0!==n[t]&&(o=n[t][s]),void 0===o)return console.warn("No api column for request column",s,"for itemType",t),null;this.enableCaching&&(o=this.columnHandler.setColumn(t,o));var c=this.response;return void 0===c[t]&&(c[t]={}),void 0===c[t][s]&&(c[t][s]=o),this.getColumnInfo(s,t,i.children,r,n)},e.prototype.getColumnInfo=function(e,t,r,n,o){var i=this.columnUtil,s=o[t][e],c=this.columnInfoFactory.construct(s,n),a=null!==n;if(a?this.derived.push(c):this[i.isItemColumn(s)?"item":"notItem"].push(c),i.isFormattedColumn(s)&&this.formatted[a?"derived":"main"].push(c),i.isFilteredColumn(s)&&this.filtered.push(c),i.isSearchableColumn(s)&&this.searchable.push(c),i.isCustomColumn(s)&&this.custom.push(c),"link"===s.type&&(this.link=c),0===r.length)return this.leaf.push(c),c;for(var u=[],l=0,h=r;l<h.length;l++){var p=h[l],f=this.getRequestColumnInfo(p,s.itemType,c,o);null!==f&&u.push(f)}return c.setChildren(s.itemType,u)},e.prototype.getColumnSetExpansion=function(e,t){return{request:this.columnUtil.mergeRequestColumns(this.request,e),response:this.columnUtil.mergeResponseColumns(this.response,t).merged}},e.prototype.getMergedColumnSet=function(e,t){var r=this.columnSetFactory.construct(this.itemType,e.request.merged,e.response);return r.requestColumnsTrue=this.requestColumnsTrue||t,r},e.prototype.merge=function(e){return this.getMergedColumnSet(this.getColumnSetExpansion(e.request,e.response),e.requestColumnsTrue)},e.prototype.expand=function(e,t,r){var n=this.getColumnSetExpansion(e,r);return{merged:this.getMergedColumnSet(n,t),difference:this.columnSetFactory.construct(this.itemType,n.request.difference,n.response,!1,!1)}},e}(),Oe=function(){function e(e){this.requestColumns=e,this.cache={}}return e.prototype.run=function(e){var t=this.cache,r=e.id;return void 0!==t[r]?t[r]:t[r]=e.isSupersetOf(this.requestColumns)},e}(),we=function(){function e(){}return e.prototype.getColumnPath=function(e,t){for(var r="",n="",o=0,i=e;o<i.length;o++){n+=r+i[o].id,r=A}return null!==t&&(n+=":"+t),n},e.prototype.getDateFormatOptions=function(e){var t=n(),r={"J-M-Y":t.format("DD-MM-YYYY"),"J-M":t.format("DD-MM"),"j+F+Y":t.format("D MMM YYYY"),"D+j+F+Y":t.format("dddd D MMM YYYY"),F:t.format("MMM"),f:t.format("MMMM"),D:t.format("dddd"),d:t.format("ddd")};return"datetime"===e&&m(r,{"J-M-Y+H:i":t.format("DD-MM-YYYY HH:mm"),"J-M+H:i":t.format("DD-MM HH:mm"),"j+F+Y+H:i":t.format("DD MMMM Y HH:mm"),"D+j+F+Y+H:i":t.format("dddd DD MMM Y HH:mm"),"H:i":t.format("HH:mm")}),r},e.prototype.isStringColumn=function(e){switch(e.type){case"email":case"phone":case"url":case"text":case"longtext":case"textreplace":return!0;default:return!1}},e.prototype.isFloatColumn=function(e){switch(e.type){case"double":case"volume":case"weight":case"distance":case"dimension":case"power":case"current":case"price":case"percentage":return!0;default:return!1}},e.prototype.isIntColumn=function(e){switch(e.type){case"int":case"number":case"quantity":return!0;default:return!1}},e.prototype.isNumberColumn=function(e){return this.isFloatColumn(e)||this.isIntColumn(e)},e.prototype.isCustomColumn=function(e){return"customfield"===e.fieldtype},e.prototype.isItemColumn=function(e,t){switch(void 0===t&&(t=!0),e.type){case"id":return t;case"item":case"child":case"sibling":case"link":return!0;default:return!1}},e.prototype.isDateColumn=function(e){switch(e.type){case"datetime":case"date":return!0;default:return!1}},e.prototype.isRenderedColumn=function(e){switch(e.type){case"datetime":case"date":case"duration":return!0;default:return!1}},e.prototype.isFilteredColumn=function(e){if("staffel"===e.id)return!0;if(void 0!==e.generator)return!0;switch(e.type){case"price":case"bool":case"enum":case"country":case"volume":case"weight":case"distance":case"dimension":case"quantity":case"email":case"url":case"datetime":case"date":case"time":case"duration":case"html":case"textreplace":case"longtext":case"percentage":return!0;default:return!1}},e.prototype.isFormattedColumn=function(e){switch(e.type){case"datetime":case"date":case"time":case"duration":case"color":case"json":case"number":case"filesize":return!0;default:return!1}},e.prototype.isSelectableColumn=function(e){switch(e.type){case"blob":case"coordinate":case"forceupdate":case"id":case"json":case"order":case"parentid":case"parenttype":case"password":case"token":return!1}return!0},e.prototype.hasLocationProperty=function(e,t){return 0!=(t&e.location)},e.prototype.isEditableColumn=function(e){if(e.readOnly)return!1;switch(e.type){case"date":case"datetime":case"duration":return!1}return!0},e.prototype.isSearchableColumn=function(e){switch(e.type){case"email":case"phone":case"text":case"longtext":case"html":return!0;default:return!1}},e.prototype.getDefaultWeight=function(e){switch(e.type){case"double":case"price":case"bool":case"int":case"percentage":case"color":case"number":case"power":case"current":return.5;case"url":case"enum":case"email":case"text":case"item":case"link":return 1.5;case"longtext":case"html":case"textreplace":return 2;case"date":case"datetime":case"time":case"duration":default:return 1}},e.prototype.getComparators=function(e){switch(e.type){case"dimension":case"weight":case"price":return["=",">","<"];case"date":case"datetime":case"time":case"duration":return[">","<"];default:return["=","!="]}},e.prototype.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findRequestColumn(r.id,t);if(-1===n)return!1;if(0===r.children.length)return!0;if("string"==typeof t[n])return!1;for(var o=0,i=r.children;o<i.length;o++){var s=i[o];if(!this.containsColumn(s,t[n][r.id]))return!1}return!0},e.prototype.containsDerivedColumns=function(e){for(var t in e)if(this.parseRequestColumn(t).children.length>0)return!0;return!1},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,o=t;n<o.length;n++){var i,s=o[n],c=this.parseRequestColumn(s),a=c.children,u=r[e];if(void 0===u)return!1;if(void 0===(i=u[c.id]))return!1;if(a.length>0&&!this.responseColumnsAvailable(i.itemType,a,r))return!1}return!0},e.prototype.copyRequestColumns=function(e){if(!0===e)return!0;for(var t=[],r=0,n=e;r<n.length;r++){var o=n[r];t.push(this.copyRequestColumn(o))}return t},e.prototype.copyRequestColumn=function(e){var t,r=this.parseRequestColumn(e);if(0===r.children.length)return r.id;for(var n=[],o=0,i=r.children;o<i.length;o++){var s=i[o];n.push(this.copyRequestColumn(s))}return(t={})[r.id]=n,t},e.prototype.mergeRequestColumns=function(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};for(var r=this.copyRequestColumns(e),n=[],o=0,i=t;o<i.length;o++){var s=i[o],c=this.mergeRequestColumn(s,r);null!==c&&n.push(c)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r,n,o=this.parseRequestColumn(e),i=this.findRequestColumn(o.id,t);if(-1===i)return t.push(e),e;if(0===o.children.length)return null;"string"==typeof t[i]&&(t[i]=((r={})[o.id]=[],r));for(var s=[],c=0,a=o.children;c<a.length;c++){var u=a[c],l=this.mergeRequestColumn(u,t[i][o.id]);null!==l&&s.push(l)}return 0===s.length?null:((n={})[o.id]=s,n)},e.prototype.getRequestColumnId=function(e){if("string"==typeof e)return e;var t;for(t in e);return t},e.prototype.parseRequestColumn=function(e){if("string"==typeof e)return{id:e,children:[]};var t;for(t in e);return{id:t,children:e[t]}},e.prototype.mergeResponseColumns=function(e,t){var r={},n={};for(var o in e)if(void 0!==t[o]){var i=this.mergeResponseColumnMap(e[o],t[o]);r[o]=i.merged,n[o]=i.difference}else r[o]=e[o];for(var o in t)void 0===e[o]&&(r[o]=t[o],n[o]=t[o]);return{merged:r,difference:n}},e.prototype.mergeResponseColumnMap=function(e,t){var r={},n={};for(var o in e)r[o]=e[o];for(var o in t)w(e[o])||(r[o]=t[o],n[o]=t[o]);return{merged:r,difference:n}},e.prototype.isLocalColumnId=function(e){return"__"===e.substring(0,2)},e.prototype.processConfigColumns=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var o=n[r];this.isLocalColumnId(o)||this.processConfigColumn(this.parseConfigColumn(o),t)}return t},e.prototype.parseConfigColumn=function(e){return e.split(":")[0].split(A)},e.prototype.processConfigColumn=function(e,t){var r,n,o=e[0],i=1===e.length,s=this.findRequestColumn(o,t);i?-1===s&&t.push(o):(-1===s?s=t.push(((r={})[o]=[],r))-1:"string"==typeof t[s]&&(t[s]=((n={})[o]=[],n)),this.processConfigColumn(e.slice(1),t[s][o]))},e.prototype.findRequestColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(this.getRequestColumnId(n)===e)return r}return-1},e}(),Me=function(){function e(e,t,r,n,o,i,s,c){void 0===c&&(c=!1),this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n,this.compilation=o,this.localCollectionCache=i,this.parameterMap=s,this.breakupByParent=c,this.requests=[]}return e.prototype.finalizeRequest=function(e){for(var t=e.collections.getCollectionsWithFittingItems(),r=e.columns,n=0,o=t;n<o.length;n++){var i=o[n];r.expand(i.columns)}return e.request.columns=r.get(),e},e.prototype.setRequestParent=function(e,t){var r=t.request;return"Void"!==e&&(r.parentType=e,r.parentId={},!0)},e.prototype.run=function(){var e=this.compilation;if(this.breakupByParent)for(var t in e){var r=e[t];for(var n in r)if(!this.keyService.isLocalId(n)){var o=this.initializeRequest();this.extendRequest(r[n],this.setRequestParent(t,o)?+n:null,o),this.requests.push(this.finalizeRequest(o))}}else for(var t in e){r=e[t],o=this.initializeRequest();var i=this.setRequestParent(t,o),s=!1;for(var n in r)this.keyService.isLocalId(n)||(this.extendRequest(r[n],i?+n:null,o),s=!0);s&&this.requests.push(this.finalizeRequest(o))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{},columns:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:this.collectionMatcherFactory.construct([this.localCollectionCache,this.collectionHandler.entries],!0,!1)}},e.prototype.extendRequest=function(e,t,r){var n=r.request,o=r.items;for(var i in e)for(var s in void 0===n.itemType&&(n.itemType=i),void 0===o[i]&&(o[i]={},n.items[i]={}),e[i]){var c=e[i][s],a=f(this.compilation,[i,s]),u=n.items[i][s]={},l=f(this.parameterMap,[i,s]),h=void 0;if(null!==t&&(n.parentId[s]=t),r.columns.expand(c.columns),r.collections.expand(c),o[i][s]=c,u.values=c.formatRequest(),u.parameters=l,void 0!==a){for(var p in h=u.links={},a)for(var d in h[p]=[],a[p])h[p].push(d);this.extendRequest(a,null,r)}}},e}(),Le=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.authInterface=t,this.collectionHandler=r,this.collectionMatcherFactory=n,this.columnSetFactory=o,this.errorHandler=i,this.itemHandler=s,this.itemRequestService=c,this.keyService=a,this.localCacheFactory=u,this.localCacheManager=l,this.moduleChangesCompilationFactory=h,this.promiseInterface=p,this.queryService=f}return e.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.collectionHandler.entries.forEach(function(e){return e.queueReload()})},e.prototype.getCollectionMatcher=function(e,t){void 0===t&&(t=!0);for(var r=this.getLocalCache(),n=this.collectionMatcherFactory.construct([r.collections],!1,!0),o=0,i=e;o<i.length;o++){var s=i[o];t&&r.items.add(s),n.expand(s)}return n},e.prototype.fetchTitle=function(e,t,r){return this.itemHandler.fetchTitle(e,t,r,this.getLocalCache().items)},e.prototype.getItemById=function(e,t,r,n){void 0===r&&(r={});var o=this.getLocalCache();return this.itemHandler.fetchItem(e,t,new Y(r),o.items).then(function(e){return o.createItemResource(e,r,n)},this.errorHandler.reject)},e.prototype.getItemsById=function(e,t,r){void 0===r&&(r={});var n=this.getLocalCache();return this.itemHandler.fetchItems(e,t,new Y(r),n.items).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getItemsByQuery=function(e,t,r){var n,o=this;void 0===r&&(r={});var i=this.getLocalCache(),s=new Y(r);return this.apiRequestService.query(e,this.queryService.addParentCondition(t,s.parent),(n={},n[e]=s.columns,n)).then(function(t){return o.itemRequestService.processResponse(t,t.links[e],s.parent,o.columnSetFactory.construct(e,s.columns,t.fetchColumnsObject()))},this.errorHandler.reject).then(function(e){return i.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getNewResource=function(e,t,r,n){var o=this;void 0===t&&(t={}),void 0===r&&(r=!1);var i=this.getLocalCache();return t.edit=!0,this.itemHandler.fetchNewItem(e,new Y(t),i.items).then(function(e){var s=i.createItemResource(e.main,t,n,!0),c=o.processLinkedItems(e.linked,t,!0);return r?{main:s,linked:c}:s},this.errorHandler.reject)},e.prototype.getDuplicateById=function(e,t,r,n,o){return void 0===r&&(r={}),r.isDuplicate=!0,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=t),this.getNewResource(e,r,n,o)},e.prototype.getItemByState=function(e,t,r,n){void 0===r&&(r={});var o=this.keyService.parseStateKey(t);if(null===o){var i=t;if(!this.keyService.isLocalId(i)||this.getLocalCache().items.contains(e,i))return this.getItemById(e,i,r,n)}else if("duplicate"===o.type)return this.getDuplicateById(e,o.itemId,r,!1,n);return this.getNewResource(e,r,!1,n)},e.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:new oe(t),resource:new ce(t)}}},e.prototype.getLinkCollectionsDef=function(e,t,r,n,o){return{itemType:r,linkType:e,linkIdArray:t,linkField:n,options:{entry:new oe(o),resource:new ce(o)}}},e.prototype.getCollection=function(e,t){var r=this.getLocalCache();return this.collectionHandler.fetch(e,new oe(t),r.items,r.collections,r.deferredCollections).then(function(e){return r.createCollectionResource(e,new ce(t))},this.errorHandler.reject)},e.prototype.getCollectionFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResource(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getLinkCollection=function(e,t,r,n){void 0===n&&(n={});var o=this.getLocalCache();return n.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,new oe(n),o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResource(e,n)},this.errorHandler.reject)},e.prototype.getLinkCollections=function(e,t,r,n){var o=this.getLocalCache();return this.collectionHandler.batchFetch(e,t,r,new oe(n),o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResources(e,n)},this.errorHandler.reject)},e.prototype.getLinkCollectionsFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResources(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getAllLinkCollections=function(e,t,r){var n=this;return this.apiRequestService.query(e,{},{}).then(function(o){return n.getLinkCollections(e,o.links[e],t,r)},this.errorHandler.reject)},e.prototype.cloneItem=function(e,t){return this.addSingleItem(e.entry.clone(),t,!1)},e.prototype.cloneCollection=function(e,t,r){var n=t.parent;return void 0===n&&(n=null),this.addCollection(e.entry.clone(n,r),t)},e.prototype.saveCurrentLocalCache=function(e,t,r,n){return this.getLocalCache().save(e,t,r,n)},e.prototype.getCurrentCollections=function(){return this.getLocalCache().collections},e.prototype.getCurrentItems=function(){return this.getLocalCache().items},e.prototype.getModuleChanges=function(e){if(void 0===e&&(e=this.getLocalCache()),void 0===e.rootItem)throw new Error("itemAdministrator: No root item for local cache "+e.id);return this.moduleChangesCompilationFactory.construct(e.rootItem,e.items,e.collections).process()},e.prototype.addSingleItem=function(e,t,r,n){return void 0===t&&(t={}),void 0===n&&(n=this.getLocalCache()),n.createItemResource(n.items.add(e),t,r)},e.prototype.addSingleItems=function(e,t){for(var r=this.getLocalCache(),n=[],o=0,i=e;o<i.length;o++){var s=i[o];n.push(this.addSingleItem(s,t,!1,r))}return n},e.prototype.addCollection=function(e,t){var r=this.getLocalCache();return r.collections.add(e),r.createCollectionResource(e,t)},e.prototype.createItemResources=function(e,t,r,n){for(var o=[],i=0,s=t;i<s.length;i++){var c=s[i];o.push(n.createItemResource(c,r)),"Projectnotitie"===e&&p(n.tabRequestParameters,[c.itemType,c.itemId],[{},{no_notification:!0}])}return o},e.prototype.processLinkedItems=function(e,t,r){void 0===r&&(r=!0);for(var n=this.getLocalCache(),o={},i=0,s=e;i<s.length;i++){o[(u=s[i]).itemType]=this.createItemResources(u.itemType,u.itemEntries,t,n)}if(!r)return o;for(var c=0,a=e;c<a.length;c++){var u=a[c];this.getCollectionMatcher(u.itemEntries,!1).addToCollections()}return o},e.prototype.expandProcessLinkedItems=function(e,t){for(var r=this.getLocalCache(),n=this.promiseInterface.when({}),o=0,i=e;o<i.length;o++){var s=i[o];n=n.then(this.constructOnItemsExpanded(s.itemType,s.itemEntries,t,r),this.errorHandler.reject)}return n},e.prototype.constructOnItemsExpanded=function(e,t,r,n){var o=this;return function(i){return o.expandAddToCollections(e,t,null,n).then(function(){return i[e]=o.createItemResources(e,t,r,n),i},o.errorHandler.reject)}},e.prototype.expandAddToCollections=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=this.getLocalCache());for(var o=this.collectionMatcherFactory.construct([n.collections],!1,!1),i=0,s=t;i<s.length;i++){var c=s[i];o.expand(c)}var a=this.getColumnSuperset(o.getCollectionsWithFittingItems());return null===a?this.promiseInterface.when(null===le?null:[]):this.itemHandler.expandLocalEntries(e,t,a.request,a.response,n.items).then(function(){return o.addToCollections(r)},this.errorHandler.reject)},e.prototype.getColumnSuperset=function(e){var t={};if(0===e.length)return null;for(var r=e[0].columns,n=1;n<e.length;n++){var o=e[n].columns;!0!==t[o.id]&&(t[o.id]=!0,r=r.merge(o))}return r},e.prototype.getLocalCache=function(){return this.localCacheManager.getCurrentLocalCache(this.authInterface.getUniqueUserId())},e.prototype.resetLocalCache=function(){var e=this.getLocalCache(),t=this.localCacheFactory.construct();e.clearResources(),this.localCacheManager.setCurrentLocalCache(this.authInterface.getUniqueUserId(),t)},e.prototype.addToCollections=function(e,t){return this.getCollectionMatcher(e).addToCollections(t)},e.prototype.removeFromCollections=function(e,t){return this.getCollectionMatcher(e,!1).removeFromCollections(t)},e.prototype.saveLocal=function(e){var t=e.entry;return t.setDisplayName(),this.addToCollections([t]),this.promiseInterface.when(e)},e.prototype.updateItemIdMap=function(e,t){if(void 0!==t)for(var r in t){var n=t[r];void 0!==e[r]&&(e[n]=e[r],delete e[r])}},e.prototype.createCollectionResource=function(e,t){return this.addCollection(e,t)},e.prototype.createItemResource=function(e,t,r){return this.addSingleItem(e,t,r)},e.prototype.onBeforeSave=function(e,t,r){return this.getLocalCache().onBeforeSave(e,t,r)},e.prototype.onSaveSuccess=function(e,t,r){return this.getLocalCache().onSaveSuccess(e,t,r)},e}(),Te=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.getByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];i.isDeferred()||this.matchQuery(i,t)&&n.push(i)}return n},e.prototype.getLocalByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];i.isLocal()&&(this.matchQuery(i,t)&&n.push(i))}return n},e.prototype.getByParent=function(e,t,r){var n=this.entries[r],o=[];if(void 0===n)return o;for(var i in n){var s=n[i],c=s.parent;null!==c&&(c.itemType===e&&c.itemId==t&&o.push(s))}return o},e.prototype.batchGetLocalByParent=function(e,t,r,n){for(var o=this.entries[r],i={},s=0,c=t;s<c.length;s++){i[c[s]]=[]}if(void 0===o)return i;for(var a in o){var u=o[a],l=u.parent;null!==l&&(l.itemType===e&&void 0!==i[l.itemId]&&u.isLocal()&&(null===n||this.matchQuery(u,n))&&i[l.itemId].push(u))}return i},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.itemId]=e},e.prototype.get=function(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]},e.prototype.contains=function(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]},e.prototype.updateItemId=function(e,t){var r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]},e.prototype.matchQuery=function(e,t){return!0===this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent).matchQuery(t.object)},e}(),xe=function(){function e(e,t){this.authInterface=e,this.keyService=t}return e.prototype.processOptions=function(e){return new Y(e)},e.prototype.createUnfoundRemoteItemError=function(){return{message:"The requested item could not be found / your current permissions are not sufficient"}},e.prototype.createUnfoundLocalItemError=function(e){return{message:"A local item of type "+e+" could not be found"}},e.prototype.createLocalConversionMap=function(e,t,r,n){void 0===r&&(r=!1);var o=n.links[e][0],i={};return i[e]={},i[e][o]=t,r&&this.expandLocalConversionMap(e,o,n,i),i},e.prototype.expandLocalConversionMap=function(e,t,r,n){var o=r.items[e][t].links;for(var i in o){var s=o[i];void 0===n[i]&&(n[i]={});for(var c=0,a=s;c<a.length;c++){var u=a[c];n[i][u]=this.keyService.getLocalId(),this.expandLocalConversionMap(i,u,r,n)}}},e.prototype.expandConversionMap=function(e,t,r){var n,o=e.itemType,i=e.itemId;return void 0===t[o]&&(t[o]={}),void 0!==(n=t[o])[i]?n[i]:(void 0===r&&(r=this.keyService.getLocalId()),n[i]=r)},e.prototype.batchExpandConversionMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var o=n[r];this.expandConversionMap(o,t)}return t},e.prototype.getConversionValue=function(e,t,r){if(void 0!==r[e])return r[e][t]},e.prototype.batchClone=function(e,t){void 0===t&&(t={});var r=[];this.batchExpandConversionMap(e,t);for(var n=0,o=e;n<o.length;n++){var i=o[n];r.push(i.clone(t))}return r},e.prototype.getFullName=function(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)},e.prototype.getTitleField=function(e){switch(e){case"Exemplaar":return"serienummer";case"Factuur":return"nummer";case"Files":return"friendlyname";case"Functie":case"Standaardfunctie":return"naamintern";case"Voorraadmutatie":return"omschrijving";case"Barcode":return"code";case"Betaalmiddel":case"Betalingsconditie":case"Briefpapier":case"TaxClass":case"TaxSchema":case"Condition":case"Factuurmoment":case"Functiegroep":case"Grootboek":case"Inhuur":case"Inhuurgroep":case"Inhuurmateriaal":case"Materiaal":case"MateriaalCat":case"Medewerkertarief":case"Notitie":case"Planningmateriaal":case"Project":case"Staffelgroep":case"Subproject":case"Taak":case"Tag":case"Template":case"Tijd":case"Titel":case"Type":case"Voertuig":return"naam";default:return"displayname"}},e.prototype.getLocalDefaultValues=function(){return{permissions:"7",creator:this.authInterface.getUserId(),created:n()}},e.prototype.hasLocalDefaultValue=function(e){switch(e){case"permissions":case"creator":case"created":return!0;default:return!1}},e}(),je=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h,p,f,d){this.apiFormatter=e,this.apiRequestService=t,this.batchStatusFactory=r,this.columnExpansionFactory=n,this.columnHandler=o,this.columnSetFactory=i,this.columnSubsetCacheFactory=s,this.columnUtil=c,this.errorHandler=a,this.itemCacheFactory=u,this.itemEntryFactory=l,this.itemEntryService=h,this.keyService=p,this.promiseService=f,this.templateFactory=d,this.templates={},this.entries=this.itemCacheFactory.construct()}return e.prototype.fetchItem=function(e,t,r,n){var o=this.getEntryStatus(e,t,r.parent,r.deferRequest,n,!0,this.columnSubsetCacheFactory.construct(r.columns));return null===o?this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(e)):this.resolveCached(o.entry,o.status,r,n)},e.prototype.fetchNewItem=function(e,t,r){var n=this,o=r.add(this.itemEntryFactory.constructDeferred(e,t.isDuplicate?this.keyService.getLocalDuplicateId():this.keyService.getLocalId(),!0,!1));return this.fetchTemplate(e,t.templateOptions,t.templateColumns).then(function(e){return n.resolveLocal(o,t.parent,e,r)},function(e){return o.reject(e),n.errorHandler.reject(e)})},e.prototype.createBatchStatus=function(e,t,r,n,o,i,s){for(var c=this.columnSubsetCacheFactory.construct(n),a=this.batchStatusFactory.construct(e,function(e){return e.itemId},function(e){return e.deferred.promise}),u=!0,l=0,h=t;l<h.length;l++){var p=h[l],f=this.getEntryStatus(e,p,r,o,i,s,c);null!==f?a.add(f):u=!1}return{batchStatus:a,success:u}},e.prototype.fetchItems=function(e,t,r,n){var o,i,s=this,c=this.errorHandler,a=r.columns,u=this.createBatchStatus(e,t,r.parent,a,r.deferRequest,n,!0),l=u.batchStatus,h=u.success;return l.hasRequests()?i=(o=this.requestItems(e,l.getRequestIds(),a)).then(function(e){return e.fetchColumnsObject()},function(e){return l.forEachEntry([T.RESOLVE],function(e){return s.clearItem(e,n)}),c.reject(e)}):l.hasEntries(l.localExpandStatus)?(o=null,i=this.columnHandler.fetch(e,a)):(o=null,i=null),this.promiseService.all({entries:l.getPromises(),response:o,columns:i}).then(function(e){return s.handleBatchResponse(l,n,a,e.response,e.columns)},c.reject).then(function(e){return e&&h?l.getArray():c.reject()},c.reject)},e.prototype.handleBatchResponse=function(e,t,r,n,o,i){var s=this,c=e.itemType,a=[T.RESOLVE],u=!0;if(e.hasEntries(a)){var l=this.columnSetFactory.construct(c,r,o);e.forEachEntry(a,function(e){s.resolveRemote(e,l,n,t)||(u=!1)})}return e.forEachEntry([T.RESOLVE_VALUES],function(e){s.resolveRemoteValues(e,n)||(u=!1)}),e.hasEntries(e.remoteExpandStatus)&&(void 0===i&&(i=this.columnExpansionFactory.construct(c,r,o)),e.forEachEntry(e.remoteExpandStatus,function(e){return s.resolveExpansion(e,i,n)})),e.hasEntries(e.localExpandStatus)?this.expandLocalEntries(c,e.getArray(e.localExpandStatus),r,o,t).then(function(e){for(var t=0,r=e;t<r.length;t++){r[t].resolve()}return u},this.errorHandler.reject):this.promiseService.when(u)},e.prototype.resolveCached=function(e,t,r,n){var o,i=this,s=function(t){e.reject(t)};switch(t){case T.LOCAL:case T.CACHED:return this.promiseService.when(e);case T.PROMISED:return e.deferred.promise;case T.EXPAND:return o=this.getColumnDifference(e,r.columns),this.requestItem(e,o).then(function(t){i.resolveExpansion(e,i.columnExpansionFactory.construct(e.itemType,o,t.fetchColumnsObject()),t)},s),e.deferred.promise;case T.EXPAND_LOCAL:return o=this.getColumnDifference(e,r.columns),this.columnHandler.fetch(e.itemType,o).then(function(t){return i.expandLocalEntries(e.itemType,[e],o,t,n).then(function(){return e.resolve()},s)},s),e.deferred.promise;case T.PROMISED_EXPAND:case T.PROMISED_EXPAND_LOCAL:return e.deferred.promise.then(function(){return i.resolveCached(e,i.getCachedEntryStatus(e,i.columnSubsetCacheFactory.construct(r.columns)),r,n)},this.errorHandler.reject);case T.RESOLVE_VALUES:return this.requestItem(e).then(function(t){i.resolveRemoteValues(e,t)},function(t){e.reject(t)}),e.deferred.promise;case T.RESOLVE:return this.requestItem(e).then(function(t){i.resolveRemote(e,e.columns.resolve(t.fetchColumnsObject()),t,n)},function(t){i.clearItem(e,n),e.reject(t)}),e.deferred.promise}},e.prototype.getColumnDifference=function(e,t){return this.columnUtil.mergeRequestColumns(e.columns.request,t).difference},e.prototype.resolveLocal=function(e,t,r,n){var o=e.itemType,i=e.itemId,s=this.itemEntryService.createLocalConversionMap(o,i,!0,r.response);return e.columns=r.columns,null!==t&&e.setParent(t.itemType,t.itemId),e.setLocalFields(r.fields,s).resolve(),{main:e,linked:this.createLocalEntries(o,i,r,s,n)}},e.prototype.resolveExpansion=function(e,t,r){var n=e.itemType,o=e.itemId,i=t.run(e.columns);return null===i?e:(e.expand(r.fetchObject(n,o),r.fetchDerivedObject(n,o,i.difference.root),i),e.resolve())},e.prototype.clearItem=function(e,t){this.entries.clear(e),t.clear(e)},e.prototype.resolveRemote=function(e,t,r,n){var o=this.getResponseFields(e,t,r);return null===o?(this.clearItem(e,n),e.reject(),!1):(e.resolveDeferred(o.initial,o.derived,t),!0)},e.prototype.resolveRemoteValues=function(e,t){var r=this.getResponseFields(e,e.columns,t);return null===r?(e.reject(),!1):(e.updateFields(r.initial,r.derived,!1).resolve(),!0)},e.prototype.getResponseFields=function(e,t,r){var n=e.itemType,o=e.itemId,i=r.fetchObject(n,o);return void 0===i?null:{initial:i,derived:r.fetchDerivedObject(n,o,t.root)}},e.prototype.fetchTemplate=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r={});var o=s(t),i=c(r);if(!o){var a=this.templates[e];if(void 0!==a&&(null===i||this.columnUtil.responseColumnsAvailable(i,r[i],a.responseColumns)))return this.promiseService.when(a)}return this.promiseService.all({template:this.apiRequestService.template(e,t),additionalColumns:null===i?{}:this.columnHandler.fetch(i,r[i])}).then(function(t){var r=t.template,i=n.templateFactory.construct(e,r,t.additionalColumns);return!o&&r.cacheable&&(n.templates[e]=i),i},this.errorHandler.reject)},e.prototype.getEntryStatus=function(e,t,r,n,o,i,s){var c;return this.keyService.isLocalId(t)?void 0!==(c=o.get(e,t))?{entry:c,status:this.getCachedEntryStatus(c,s)}:null:void 0!==(c=this.entries.get(e,t))?{entry:i?o.add(c):c,status:this.getCachedEntryStatus(c,s)}:(c=this.itemEntryFactory.constructDeferred(e,t,s.requestColumns,n),null!==r&&c.setParent(r.itemType,r.itemId),i&&o.add(c),this.entries.add(c),{entry:c,status:n?T.PROMISED:T.RESOLVE})},e.prototype.getCachedEntryStatus=function(e,t){var r=e.columns;return e.isDeferred()?e.deferRequest?(r.expandRequestColumns(t.requestColumns),T.RESOLVE):t.run(r)?T.PROMISED:e.isLocal()?T.PROMISED_EXPAND_LOCAL:T.PROMISED_EXPAND:t.run(r)?e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?T.CACHED:(e.defer(),T.RESOLVE_VALUES)):T.CACHED:(e.defer(),e.isLocal()?T.EXPAND_LOCAL:T.EXPAND)},e.prototype.fetchTitle=function(e,t,r,n){void 0===r&&(r=!0);var o=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,new Y({columns:[o],deferRequest:r}),n).then(function(e){return e.getFields()[o]},this.errorHandler.reject)},e.prototype.createLocalEntries=function(e,t,r,n,o,i){var s=this;void 0===i&&(i=function(){return!0});var c=r.response,a={},u={},l=[],h=function(e,t,p){var f={itemType:e,itemId:t},d=c.items[e][p].links;for(var m in d)if(d.hasOwnProperty(m)){void 0===a[m]&&l.push({itemType:m,itemEntries:a[m]=[],columnSet:u[m]=s.columnSetFactory.construct(m,!0,r.responseColumns)});for(var y=0,v=d[m];y<v.length;y++){var g=v[y],C=n[m][g],I=s.itemEntryFactory.constructLocalLinked(m,C,c.fetchObject(m,g),f,u[m],n);i(I)&&(o.add(I),a[m].push(I),h(m,C,g))}}};return h(e,t,c.links[e][0]),l},e.prototype.expandLocalEntries=function(e,t,r,n,o){if(0===t.length)return this.promiseService.when(t);for(var i=this.columnExpansionFactory.construct(e,r,n),s=0,c=t;s<c.length;s++){var a=c[s],u=i.run(a.columns);null!==u&&a.expandLocal(u)}return this.resolveDerivedValues(t,i.aggregateRootColumns(),o)},e.prototype.resolveDerivedValues=function(e,t,r){for(var n=[],o=0,i=t;o<i.length;o++){var s=i[o];n.push(this.fetchDerivedValuesByColumn(e,s,r))}return this.promiseService.all(n).then(function(){return e},this.errorHandler.reject)},e.prototype.setDefaultValuesByColumn=function(e,t){var r=t.children;if(0!==r.length)for(var n=0,o=r;n<o.length;n++)for(var i=o[n],s=0,c=e;s<c.length;s++){c[s].derived[i.path]=this.apiFormatter.getDefaultValue(i.apiColumn.type)}},e.prototype.getItemIdByColumn=function(e,t){return 0===t.level?"link"===t.apiColumn.type&&null!==e.parent?e.parent.itemId:e.getFields()[t.path]:e.derived[t.path]},e.prototype.fetchDerivedValuesByColumn=function(e,t,r){var n=this,o=t.children;if(0===o.length)return this.promiseService.when();var i=o[0];if(1===o.length&&"id"===i.apiColumn.type){for(var s=0,c=e;s<c.length;s++){(h=c[s]).derived[i.path]=this.getItemIdByColumn(h,t)}return this.promiseService.when()}for(var a={},u=0,l=e;u<l.length;u++){var h=l[u],p=this.getItemIdByColumn(h,t);void 0===a[p]&&(a[p]=[]),a[p].push(h)}void 0!==a.null&&this.setDefaultValuesByColumn(a.null,t);var f=[];for(var p in a)"null"!==p&&f.push(+p);if(0===f.length)return this.promiseService.when();for(var d=[],m=0,y=o;m<y.length;m++){var v=y[m];d.push(v.id)}return this.fetchItems(t.itemType,f,new Y({columns:d}),r).then(function(t){for(var i=0,s=t;i<s.length;i++)for(var c=s[i],u=c.getFields(),l=0,h=a[c.itemId];l<h.length;l++)for(var p=h[l],f=0,d=o;f<d.length;f++){var m=d[f];p.derived[m.path]=u[m.id]}return n.resolveDerivedValues(e,o,r)},this.errorHandler.reject)},e.prototype.requestItem=function(e,t){return void 0===t&&(t=e.columns.request),this.requestItems(e.itemType,[e.itemId],t)},e.prototype.requestItems=function(e,t,r){var n;return this.apiRequestService.query(e,{id:t},((n={})[e]=r,n))},e}(),ke=function(){function e(e,t,r,n,o,i,s,c){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnExpansionFactory=n,this.columnSetFactory=o,this.itemEntryFactory=i,this.queryService=s,this.promiseService=c}return e.prototype.requestItem=function(e,t,r){var n,o=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},o)},e.prototype.requestItems=function(e,t,r){var n;void 0===t&&(t=e.query.object),void 0===r&&(r=e.options.columns);var o=e.itemType;return this.apiRequestService.requestSkeleton({requestType:"query",itemType:o,columns:(n={},n[o]=r,n),query:t,limit:e.options.limit})},e.prototype.requestLinkItems=function(e,t,r,n,o){var i,s=((i={})[r]=o,i);return null===n?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}}),s)},e.prototype.processExpansion=function(e,t,r,n){for(var o=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject()),i=0,s=n;i<s.length;i++){var c=s[i];c.isLocal()||this.handleCachedItem(c,t,o)}return o},e.prototype.processResponse=function(e,t,r,n,o){var i=this;void 0===o&&(o=this.columnExpansionFactory.construct(n.itemType,!!n.requestColumnsTrue||n.request,n.response));for(var s=this.itemHandler,c=n.itemType,a=n.root,u=[],l=[],h=0,p=t;h<p.length;h++){var f=p[h],d=s.entries.get(c,f);void 0===d?(d=this.itemEntryFactory.construct(f,e.fetchObject(c,f),e.fetchDerivedObject(c,f,a),n),s.entries.add(d),u.push(d)):d.isDeferred()?d.deferRequest?u.push(d.resolveDeferred(e.fetchObject(c,f),e.fetchDerivedObject(c,f,a),n)):l.push(d.deferred.promise):d.reloadQueued?(d.reloadQueued=!1,d.updateFields(e.fetchObject(c,f),e.fetchDerivedObject(c,f,a),!1),u.push(d)):u.push(this.handleCachedItem(d,e,o)),null!==r&&(d.parent=r)}return this.promiseService.all(l).then(function(t){for(var r=0,n=t;r<n.length;r++){var s=n[r];u.push(i.handleCachedItem(s,e,o))}return u},this.errorHandler.reject)},e.prototype.handleCachedItem=function(e,t,r){var n=r.run(e.columns);return null===n?e:e.expand(t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,n.difference.root),n)},e.prototype.processLinkResponse=function(e,t,r,n,o){for(var i=e.fetchColumnsObject(),s=this.columnSetFactory.construct(n,o.columns,i),c=this.columnExpansionFactory.construct(n,o.columns,i),a=e.items[t],u={},l=0,p=r;l<p.length;l++){var f=p[l];u[f]=h(a,[f,"links",n])?this.processResponse(e,a[f].links[n],{itemType:t,itemId:f},s,c):[]}return this.promiseService.all(u).then(function(e){return{items:e,columns:s,columnExpansion:c}},this.errorHandler.reject)},e}(),De=function(){function e(){this.separator=":"}return e.prototype.getSingleKey=function(e,t){return e+this.separator+t},e.prototype.getCssKey=function(){return Array.prototype.join.call(arguments,"_")},e.prototype.parseStateKey=function(e){return"new-"===(e=e.toString()).substring(0,"new-".length)?{type:"new",template:e.substring("new-".length)}:"dup-"===e.substring(0,"dup-".length)?{type:"duplicate",itemId:+e.substring("dup-".length)}:null},e.prototype.getDuplicateStateKey=function(e){return"dup-"+e},e.prototype.getNewStateKey=function(e){return"new-"+e},e.prototype.getLocalId=function(){return+("-1"+this.getRandomString())},e.prototype.getLocalDuplicateId=function(){return+("-2"+this.getRandomString())},e.prototype.getRandomString=function(){return(""+Math.random()).split(".")[1].substr(0,8)},e.prototype.isLocalId=function(e){return void 0!==e&&(this.isNewId(e)||this.isDuplicateId(e))},e.prototype.isNewId=function(e){return"new-"===e||"-1"===(""+e).substring(0,"-1".length)},e.prototype.isDuplicateId=function(e){return"dup-"===e||"-2"===(""+e).substring(0,"-2".length)},e}();!function(e){e.Always="always",e.OnClose="onClose",e.SkipOnClose="skipOnClose"}(B||(B={}));var Ae,He=function(){function e(e,t,r,n,o,i,s,c,a){void 0===a&&(a=""),this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=o,this.itemCacheFactory=i,this.collectionResourceFactory=s,this.promiseService=c,this.id=a,this.tabRequestParameters={},this.isSaving=!1,this.callbacks={onBeforeSave:{always:{},onClose:{},skipOnClose:{}},onSaveSuccess:{always:{},onClose:{},skipOnClose:{}}},this.changesInterval=null,this.hasChanges=!1,this.items=this.itemCacheFactory.construct(),this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct()}return e.prototype.createItemResource=function(e,t,r,n){var o=this;return void 0===r&&(r=!1),r&&(this.rootItem=e),t.onDeactivate=function(e){return o.onDeactivateItem(e)},this.itemResourceFactory.construct(e,t,n)},e.prototype.createItemResources=function(e,t){var r=this;t.onDeactivate=function(e){return r.onDeactivateItem(e)};for(var n=this.itemResourceFactory.getConstructor(t),o=[],i=0,s=e;i<s.length;i++){var c=s[i];o.push(n(c))}return o},e.prototype.createCollectionResource=function(e,t){return this.collectionResourceFactory.construct(e,t,this)},e.prototype.createCollectionResources=function(e,t){var r={};for(var n in e)r[n]=this.createCollectionResource(e[n],t);return r},e.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},e.prototype.clearItemEntry=function(e){this.items.clear(e),e.clearResources()},e.prototype.clearCollection=function(e){var t=e.entry;this.collections.clear(t),t.clearResources()},e.prototype.clearResources=function(e){void 0===e&&(e=!1),this.items.forEach(function(e){return e.clearResources()}),this.collections.forEach(function(t){return t.clearResources(e)}),this.deferredCollections.clear()},e.prototype.updateSingleItems=function(e){for(var t in e)for(var r in e[t]){var n=this.items.get(t,r);void 0!==n&&this.items.updateItemId(n,r)}},e.prototype.revertChanges=function(){var e=this;return this.items.forEach(function(e){return e.resetModified()}),this.collections.forEach(function(t){return e.resetCollection(t)}),this.hasChanges=!1,this.isLockable()?this.lockService.deleteLock(this.rootItem):this.promiseService.when()},e.prototype.resetCollection=function(e){if(e.items=e.initial.slice(),e.hasItemEditResources)for(var t=0,r=e.items;t<r.length;t++){r[t].resetModified()}},e.prototype.detectChanges=function(){var e=this;return!!this.hasChanges||(this.items.some(function(e){return e.hasChanges()})?this.hasChanges=!0:this.hasChanges=this.collections.some(function(t){return e.collectionHasChanges(t)}))},e.prototype.collectionHasChanges=function(e){return!(!e.hasEditResources||!e.hasAddedItems()&&!e.hasRemovedItems())||e.hasItemEditResources&&e.hasUpdatedItems()},e.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},e.prototype.save=function(e,t,r,n){var o=this;return void 0===e&&(e=!1),void 0===t&&(t={}),this.isSaving?this.errorHandler.reject():(this.isSaving=!0,this.detectChanges(),this.disableChangesWatcher(),(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(function(){return o.executeCallbackEvent(o.callbacks.onBeforeSave,function(e){return e(o)},e)},this.errorHandler.reject).then(function(){var e=m({},o.tabRequestParameters,t);return o.tabRequestParameters={},o.changesProcessorFactory.construct().execute(o.items.toArray(),o.collections.toArray(),e,r,n)},this.errorHandler.reject).then(function(t){return o.isLockable()&&o.lockService.clearLock(o.rootItem),o.hasChanges=!1,e||o.updateSingleItems(t),o.executeCallbackEvent(o.callbacks.onSaveSuccess,function(e){return e(o,t)},e).then(function(){return e||o.enableChangesWatcher(),o.isSaving=!1,t},o.errorHandler.reject)},this.errorHandler.reject).catch(function(e){return o.isSaving=!1,o.errorHandler.reject(e)}))},e.prototype.onBeforeSave=function(e,t,r){void 0===r&&(r=B.Always);var n=this.callbacks.onBeforeSave[r];return n[e]=t,function(){return delete n[e]}},e.prototype.onSaveSuccess=function(e,t,r){void 0===r&&(r=B.Always);var n=this.callbacks.onSaveSuccess[r];return n[e]=t,function(){return delete n[e]}},e.prototype.executeCallbackEvent=function(e,t,r){var n=this;return this.executeCallbacks(e[B.Always],t).then(function(){return n.executeCallbacks(e[r?B.OnClose:B.SkipOnClose],t)},this.errorHandler.reject)},e.prototype.executeCallbacks=function(e,t){var r={};for(var n in e)r[n]=t(e[n]);return this.promiseService.all(r)},e.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},e.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},e.prototype.onDeactivateItem=function(e){this.clearItemEntry(e)},e.prototype.onActivateItem=function(e){this.items.add(e)},e}(),Pe=function(){function e(e,t,r,n){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=n,this.lockItems={},this.promises={}}return e.prototype.getValue=function(e,t){var r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]},e.prototype.setValue=function(e,t,r){return p(r,[e.itemType,e.itemId],[{},t])},e.prototype.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){for(var t in this.lockItems)for(var r in this.lockItems[t]){var n=this.lockItems[t][r];if(!n.isForeign&&n.id==e)return!0}return!1},e.prototype.isLocked=function(e){var t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign},e.prototype.getMessage=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message},e.prototype.fetchCachedLock=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);var r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()},e.prototype.fetchLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},this.errorHandler.reject).then(function(e){return e.isForeign?t.errorHandler.reject(e.message):e.token},this.errorHandler.reject)},e.prototype.requestLock=function(e){var t=this,r=e.itemType,n=e.itemId,o=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:r,item:n}).then(function(o){return delete t.promises[r][n],t.setValue(e,o.fetchObject("Locktoken",o.links.Locktoken[0]),t.lockItems)},function(o){return delete t.promises[r][n],301===o.code?t.setValue(e,{isForeign:!0,message:o.message},t.lockItems):t.errorHandler.reject(o)});return this.setValue(e,o,this.promises)},e.prototype.deleteLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){if(void 0!==r){if(!r.isForeign)return t.apiRequestService.delete("Locktoken",r.id).then(function(){t.clearLock(e)},t.errorHandler.reject);t.clearLock(e)}},this.errorHandler.reject)},e.prototype.clearLock=function(e){var t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]},e}(),_e={},Ve=function(){function e(e,t,r){this.rootItemEntry=e,this.singleItemCache=t,this.collectionCache=r,this.parentMap={},this.destination={}}return e.prototype.process=function(){return this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{}),{itemType:this.rootItemEntry.itemType,itemId:this.rootItemEntry.itemId,items:this.destination}},e.prototype.createParentMap=function(e){var t={};return e.forEach(function(e){var r=e.itemType,n=e.parent;if(null!==n){var o=n.itemType,i=n.itemId;void 0===t[o]&&(t[o]={});var s=t[o];void 0===s[i]&&(s[i]={}),void 0===(s=s[i])[r]&&(s[r]=[]),s[r].push(e)}}),t},e.prototype.processItems=function(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(var n=0,o=t;n<o.length;n++){var i=o[n],s=i.itemId;void 0===this.destination[e][s]&&(r[e].push(s),this.destination[e][s]=this.processItem(i))}},e.prototype.processItem=function(e){var t=e.itemType,r=e.itemId,n=this.getItemsByParent(t,r),o=this.collectionCache.getCollectionsByParent(t,r),i=e.formatRequest(),c={};for(var a in n)this.processItems(a,n[a],c);for(var u=0,l=o;u<l.length;u++){var h=l[u];null===h.options.query&&this.processItems(h.itemType,h.items,c)}var p=s(i),f=s(c);return p&&f?{values:i,links:c}:p?{values:i}:f?{links:c}:_e},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),Be="maybe",Ne=function(){function e(e,t,r,n){void 0===n&&(n=null),this.apiFormatter=e,this.itemType=t,this.fields=r,this.parent=n}return e.prototype.compareValues=function(e,t){return n.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):n.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return Be;if(void 0!==e.custom)return Be;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!s(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){if(e.reverse)return Be;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===Be?Be:e.not?!t:t},e.prototype.matchComplexQuery=function(e){var t,r,n=e.conditions;switch(e.operator){case"AND":t=!0,r=!1;break;case"OR":t=!1,r=!0;break;default:throw new Error("queryMatcher: Unsupported operator")}for(var o=0,i=n;o<i.length;o++){var s=i[o],c=this.matchQuery(s);if(c===r)return r;c===Be&&(t=Be)}return t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,o=t.value;if(!s(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),Be;switch("NOW"===o&&(o=n()),t.comparator){case"=":return this.compareValues(e,o);case"!=":return!this.compareValues(e,o);case"<":return e<o;case"<=":return e<=o;case">":return e>o;case">=":return e>=o;case"IN":return a(e,o);case"NOT IN":return!a(e,o);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}();!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(Ae||(Ae={}));var Ue=function(){function e(e,t){this.query=e,this.parameters=t}return e.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():n.isMoment(e)?n(e):n.isDuration(e)?n.duration(e):e},e.prototype.compareParsedQueries=function(e,t){return e[Ae.STR]===t[Ae.STR]?0:e[Ae.STR]>t[Ae.STR]?1:-1},e.prototype.parse=function(e){if(void 0===e&&(e=this.query),void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);var t=c(e);return null===t?[{},"{}"]:this.parseSimpleQuery(t,e[t])},e.prototype.parseSearchQuery=function(e){return[{search:(e=this.formatValue(e))[Ae.OBJ]},"[search"+Ae.SEP+e[Ae.STR]+"]"]},e.prototype.parseCustomQuery=function(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];var r=this.parseCustomParameters(t);return[{custom:e,parameters:r[Ae.OBJ]},"["+e+Ae.SEP+r[Ae.STR]+"]"]},e.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",o=0;o<t.length;o++){var i=t[o],s=this.formatValue(e[i]);r[i]=s[Ae.OBJ],o>0&&(n+=Ae.SEP),n+=s[Ae.STR]}return[r,n]},e.prototype.parseSimpleQuery=function(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[Ae.OBJ])?"IN":"="),[{key:e,value:t[Ae.OBJ],comparator:r},"["+r+Ae.SEP+e+Ae.SEP+t[Ae.STR]+"]"]},e.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var o=this.parse(t);return[{linkedTo:e,query:o[Ae.OBJ],reverse:r,not:n},"[linkedTo"+Ae.SEP+e+Ae.SEP+o[Ae.STR]+Ae.SEP+r+Ae.SEP+n+"]"]},e.prototype.parseComplexQuery=function(e,t){t=void 0===t?"AND":t.toUpperCase();var r=this.parseConditions(e);return[{conditions:r[Ae.OBJ],operator:t},"["+t+r[Ae.STR]+"]"]},e.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],o="",i=0,s=e;i<s.length;i++){var c=s[i];r.push(this.parse(c))}for(var a=0,u=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});a<u.length;a++){var l=u[a];n.push(l[Ae.OBJ]),o+=l[Ae.STR]}return[n,o]},e.prototype.formatValue=function(e){var t;if("string"==typeof e&&"&"===e.charAt(0)){var r=e.substring(1);if(void 0===(e=this.parameters[r]))throw new Error("queryParser: Undefined template parameter '"+r+"'");return[t=this.processValue(e),r+">"+e]}return[t=this.processValue(e),""+t]},e}(),Qe=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}},e.prototype.addParentCondition=function(e,t){var r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))},e.prototype.createNotIn=function(e){return{comparator:"NOT IN",key:"id",value:e}},e}(),Ye=function(){function e(e){this.columnUtil=e,this.columns={},this.columnSetIdMap={}}return e.prototype.expand=function(e){if(!this.columnSetIdMap[e.id]){var t=this.columns,r=e.itemType;void 0===t[r]&&(t[r]=[]),t[r]=this.columnUtil.mergeRequestColumns(t[r],e.request).merged,this.columnSetIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),Xe=function(){function e(e,t,r,n,o,i,s,c,a,u){this.promiseService=e,this.apiRequestService=t,this.itemHandler=r,this.itemEntryFactory=n,this.collectionHandler=o,this.columnSetFactory=i,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.apiFormatter=a,this.errorHandler=u}return e.prototype.onMessageReceived=function(e){switch(e.body.eventType){case"update":return this.handleUpdate(e);case"create":return this.handleCreate(e);case"delete":return this.handleDelete(e);case"linkTo":return this.handleLinkMove()}},e.prototype.formatMessageValues=function(e,t){var r={};for(var n in t)r[n]=this.apiFormatter.formatResponseValue(t[n].type,e[n]);return r},e.prototype.createCollectionMap=function(e,t,r){var n={};for(var o in t){var i=t[o],s=null!==i.parent?i.parent:{};n[o]=this.collectionHandler.entries.getByFittingItem(e,this.formatMessageValues(i.values,r),s)}return n},e.prototype.groupByCollectionId=function(e,t){var r={};for(var n in t){var o=t[n];for(var i in o)for(var s=0,c=o[i];s<c.length;s++){var a=c[s],u=a.id;void 0===r[u]&&(r[u]={collection:a,fitting:[],notfitting:[],maybe:[]}),r[u][i].push("fitting"===i?this.itemHandler.entries.get(e,n):n)}}return r},e.prototype.getRequestColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();for(var n in t){for(var o=t[n].fitting,i=this.itemHandler.entries.get(e,n),s=0,c=o;s<c.length;s++){var a=c[s];r.expand(a.columns)}void 0!==i&&r.expand(i.columns)}return r.get()},e.prototype.deferEntry=function(e){var t=e.deferred;return void 0===t?e.defer():t.promise.then(this.deferEntry.bind(this),this.errorHandler.reject)},e.prototype.processMessage=function(e){var t=this,r=e.itemType,n=this.createCollectionMap(r,e.items[r],e.columns[r]),o=this.getRequestColumns(r,n),i=[],s=[];for(var c in n){var a=this.itemHandler.entries.get(r,c),u=+c;void 0===a?0!==n[u].fitting.length&&(this.itemHandler.entries.add(this.itemEntryFactory.constructDeferred(r,u,o[r],!1)),s.push(u)):(i.push(this.deferEntry(a)),s.push(u))}return 0===s.length?this.promiseService.when(this.groupByCollectionId(r,n)):this.promiseService.all(i).then(function(){return t.apiRequestService.query(r,{id:s},o)},this.errorHandler.reject).then(function(e){return t.handleResponse(r,s,o[r],e,n)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=e.items.FunctionChangesResolve,n=[],o=[];for(var i in r){var s=r[i].parent.itemId,c=this.itemHandler.entries.get("Functie",s);void 0!==c&&void 0!==c.columns.response.Functie.newchanges&&(n.push(this.deferEntry(c)),o.push(s))}return 0===o.length?this.promiseService.when():this.promiseService.all(n).then(function(){return t.apiRequestService.query("Functie",{id:o},{Functie:["newchanges"]})},this.errorHandler.reject).then(function(e){for(var r=0,n=e.links.Functie;r<n.length;r++){var o=n[r],i=t.itemHandler.entries.get("Functie",o),s=t.apiFormatter.copyFields(i.getFields(),{},i.columns.main),c=e.fetchValue("Functie",o,"newchanges");c!==s.newchanges&&i.setInitial({newchanges:c},!0).callOnChange(s).resolve()}},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleResponse=function(e,t,r,n,o){for(var i=n.fetchColumnsObject(),s=this.columnSetFactory.construct(e,r,i),c=this.columnExpansionFactory.construct(e,r,i),a=0,u=t;a<u.length;a++){var l=u[a],h=this.itemHandler.entries.get(e,l),p=void 0===h.initial,f=n.fetchObject(e,l);if(void 0!==f){var d=n.fetchDerivedObject(e,l,s.root);if(p)h.resolveDeferred(f,d,s);else{var m=c.run(h.columns),y=this.apiFormatter.copyFields(h.getFields(),{},h.columns.main);null!==m&&h.expand(f,d,m),h.updateFields(f,d,!1).callOnChange(y).resolve()}}else h.reject(),p&&this.itemHandler.entries.clear(h),delete o[l]}return this.groupByCollectionId(e,o)},e.prototype.isFunctionChangesResolveMessage=function(e){return"FunctionChangesResolve"===e.body.itemType},e.prototype.handleCreate=function(e){var t=this,r=e.body;return this.isFunctionChangesResolveMessage(e)?this.processFunctionChangesResolve(r):this.processMessage(r).then(function(e){return t.collectionHandler.addToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){var t=this;return this.processMessage(e.body).then(function(e){return t.collectionHandler.removeFromAndAddToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=e.body,r={},n=0,o=t.items;n<o.length;n++)for(var i=o[n],s=0,c=this.collectionHandler.entries.getByContainingItem(t.itemType,i);s<c.length;s++){var a=c[s];void 0===r[u=a.id]&&(r[u]={collection:a,items:[]}),r[u].items.push(i)}for(var u in r){var l=r[u];l.collection.removeItems(l.items,null,!0)}return this.promiseService.when()},e.prototype.handleLinkMove=function(){return this.promiseService.when()},e}(),Je=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new k(this.apiFormatter,e)},e}(),We=function(){function e(e){this.promiseService=e}return e.prototype.construct=function(e,t,r){return new H(this.promiseService,e,t,r)},e}(),Ke=function(){function e(e,t){this.collectionCacheFactory=e,this.keyService=t}return e.prototype.construct=function(e,t){return new P(this.collectionCacheFactory,this.keyService,e,t)},e}(),ze=function(){function e(e,t,r,n,o,i,s,c,a,u,l){this.apiFormatter=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.collectionEntryService=n,this.collectionHandler=o,this.columnExpansionFactory=i,this.createRequestFactory=s,this.errorHandler=c,this.itemHandler=a,this.promiseService=u,this.requestColumnExpansionFactory=l}return e.prototype.construct=function(){return new _(this.apiFormatter,this.apiRequestService,this.changesCompilationFactory,this.collectionEntryService,this.collectionHandler,this.columnExpansionFactory,this.createRequestFactory,this.errorHandler,this.itemHandler,this.promiseService,this.requestColumnExpansionFactory)},e}(),Ge=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new N(this.queryMatcherFactory)},e}(),Ze=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h){this.collectionEntryService=e,this.columnHandler=t,this.columnExpansionFactory=r,this.columnSetFactory=n,this.errorHandler=o,this.itemEntryFactory=i,this.itemEntryService=s,this.itemHandler=c,this.itemRequestService=a,this.keyService=u,this.promiseService=l,this.queryService=h}return e.prototype.construct=function(e,t){return new ue(this,e,new oe(t))},e}(),$e=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e,t,r){return new ge(this.queryMatcherFactory,e,t,r)},e}(),et=function(){function e(e,t,r,n,o){this.errorHandler=e,this.itemResourceFactory=t,this.changesProcessorFactory=r,this.keyService=n,this.promiseService=o}return e.prototype.construct=function(e,t,r){var n=new ce(t);return n.editItems&&(e.hasItemEditResources=!0),n.editCollection?(e.hasEditResources=!0,new de(this,e,n,r)):new pe(this.itemResourceFactory,e,n,r)},e}(),tt=function(){function e(e){this.columnInfoFactory=e}return e.prototype.construct=function(e,t,r){return new Se(this.columnInfoFactory,e,t,r)},e}(),rt=function(){function e(){}return e.prototype.construct=function(e,t){return new Fe(e,t)},e}(),nt=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){return new be(this.columnHandler,this.columnUtil,this.columnInfoFactory,this,e,t)},e.prototype.construct=function(e,t,r,n,o){return this.constructStub(e,t).resolve(r,n,o)},e}(),ot=function(){function e(){}return e.prototype.construct=function(e){return new Oe(e)},e}(),it=function(){function e(e,t,r,n){this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n}return e.prototype.construct=function(e,t,r,n){return new Me(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory,e,t,r,n)},e}(),st=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new Te(this.queryMatcherFactory)},e}(),ct=function(){function e(e,t,r,n,o,i){this.authInterface=e,this.apiFormatter=t,this.columnSetFactory=r,this.itemEntryService=n,this.keyService=o,this.promiseService=i}return e.prototype.constructStub=function(e,t,r){return new z(this,e,t,r)},e.prototype.constructLocalLinked=function(e,t,r,n,o,i){var s=this.constructStub(e,t,o);return s.parent=n,s.setLocalFields(r,i)},e.prototype.constructLocal=function(e,t,r,n,o,i,s){void 0===o&&(o=null),void 0===i&&(i=t.columns);var c=t.columns.itemType;void 0===s&&(s=this.itemEntryService.createLocalConversionMap(c,e,!0,t.response));var a=this.constructStub(c,e,i);return a.parent=o,a.setLocalFields(t.fields,s,t.columns).setModified(r).setDerived(n)},e.prototype.constructDeferred=function(e,t,r,n){var o=this.constructStub(e,t,this.columnSetFactory.constructStub(e,r));return o.defer(n),o},e.prototype.construct=function(e,t,r,n){return this.constructStub(n.itemType,e,n).setFields(t,r)},e}(),at=function(){function e(e,t,r,n,o){this.apiFormatter=e,this.lockService=t,this.changesProcessor=r,this.errorHandler=n,this.promiseService=o}return e.prototype.getConstructor=function(e){var t=this,r=new W(e);return function(e){return r.edit?new te(t,e,r):new $(e,r)}},e.prototype.construct=function(e,t,r){var n=new W(t);return t.edit?new te(this,e,n,r):new $(e,n,r)},e}(),ut=function(){function e(e,t,r,n,o,i,s,c){this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=o,this.itemCacheFactory=i,this.collectionResourceFactory=s,this.promiseService=c}return e.prototype.construct=function(e){return new He(this.errorHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.promiseService,e)},e}(),lt=function(){function e(){}return e.prototype.construct=function(e,t,r){return new Ve(e,t,r)},e}(),ht=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new Ne(this.apiFormatter,e,t,r)},e}(),pt=function(){function e(){}return e.prototype.construct=function(e,t){return new Ue(e,t)},e}(),ft=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new Ye(this.columnUtil)},e}(),dt=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r){return new me(this,e,t,r)},e}(),mt=function(){return function(e,t,r,n,o){this.noop=yt,this.version="1.5.3",this.apiFormatter=new x,this.keyService=new De,this.queryService=new Qe,this.columnUtil=new we,this.apiResponseProcessorFactory=new Je(this.apiFormatter),this.apiRequestService=new j(e,this.apiResponseProcessorFactory),this.itemEntryService=new xe(r,this.keyService),this.lockService=new Pe(this.apiRequestService,n,this.keyService,o),this.queryMatcherFactory=new ht(this.apiFormatter),this.itemCacheFactory=new st(this.queryMatcherFactory),this.batchStatusFactory=new We(o),this.columnCache=new Ie(this.columnUtil),this.columnHandler=new Re(this.apiRequestService,n,o,this.columnCache,this.columnUtil),this.columnInfoFactory=new rt,this.columnSubsetCacheFactory=new ot,this.columnExpansionFactory=new tt(this.columnInfoFactory),this.columnSetFactory=new nt(this.columnHandler,this.columnUtil,this.columnInfoFactory),this.templateFactory=new dt(this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new ct(r,this.apiFormatter,this.columnSetFactory,this.itemEntryService,this.keyService,o),this.itemHandler=new je(this.apiFormatter,this.apiRequestService,this.batchStatusFactory,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnSubsetCacheFactory,this.columnUtil,n,this.itemCacheFactory,this.itemEntryFactory,this.itemEntryService,this.keyService,o,this.templateFactory),this.itemRequestService=new ke(this.apiRequestService,n,this.itemHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryFactory,this.queryService,o),this.queryParserFactory=new pt,this.collectionEntryService=new ye(this.queryParserFactory,this.queryService),this.collectionResourceService=new Ce,this.collectionEntryFactory=new Ze(this.collectionEntryService,this.columnHandler,this.columnExpansionFactory,this.columnSetFactory,n,this.itemEntryFactory,this.itemEntryService,this.itemHandler,this.itemRequestService,this.keyService,o,this.queryService),this.collectionCacheFactory=new Ge(this.queryMatcherFactory),this.collectionMatcherFactory=new $e(this.queryMatcherFactory),this.collectionHandler=new ve(this.batchStatusFactory,this.collectionCacheFactory,this.collectionEntryFactory,this.collectionEntryService,this.collectionMatcherFactory,this.columnHandler,this.columnSetFactory,n,this.itemHandler,this.itemRequestService,this.keyService,o,this.queryParserFactory,this.queryService),this.requestColumnExpansionFactory=new ft(this.columnUtil),this.createRequestFactory=new it(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory),this.changesCompilationFactory=new Ke(this.collectionCacheFactory,this.keyService),this.changesProcessorFactory=new ze(this.apiFormatter,this.apiRequestService,this.changesCompilationFactory,this.collectionEntryService,this.collectionHandler,this.columnExpansionFactory,this.createRequestFactory,n,this.itemHandler,o,this.requestColumnExpansionFactory),this.itemResourceFactory=new at(this.apiFormatter,this.lockService,this.changesProcessorFactory.construct(),n,o),this.collectionResourceFactory=new et(n,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,o),this.localCacheFactory=new ut(n,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,o),this.moduleChangesCompilationFactory=new lt,this.itemAdministrator=new Le(this.apiRequestService,r,this.collectionHandler,this.collectionMatcherFactory,this.columnSetFactory,n,this.itemHandler,this.itemRequestService,this.keyService,this.localCacheFactory,t,this.moduleChangesCompilationFactory,o,this.queryService),this.socketMessageHandler=new Xe(o,this.apiRequestService,this.itemHandler,this.itemEntryFactory,this.collectionHandler,this.columnSetFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.apiFormatter,n)}}();function yt(){}function vt(e){return e}r.d(t,"RmCore",function(){return mt}),r.d(t,"noop",function(){return yt}),r.d(t,"identity",function(){return vt}),r.d(t,"ENTRY_STATUS",function(){return T}),r.d(t,"ALL_PERMISSIONS",function(){return"7"}),r.d(t,"COLUMN_SEPERATOR",function(){return A}),r.d(t,"RENDER_AS_SEPERATOR",function(){return":"}),r.d(t,"NEW_PREFIX",function(){return"-1"}),r.d(t,"DUPLICATE_PREFIX",function(){return"-2"}),r.d(t,"NEW_KEYWORD",function(){return"new-"}),r.d(t,"DUPLICATE_KEYWORD",function(){return"dup-"}),r.d(t,"ItemEntryOptionsInterface",function(){return Q}),r.d(t,"ItemEntryOptions",function(){return Y}),r.d(t,"ItemResourceOptionsInterface",function(){return J}),r.d(t,"ItemResourceOptions",function(){return W}),r.d(t,"ItemEntry",function(){return z}),r.d(t,"ItemResource",function(){return G}),r.d(t,"ViewResource",function(){return $}),r.d(t,"EditResource",function(){return te}),r.d(t,"CollectionEntryOptionsInterface",function(){return ne}),r.d(t,"CollectionEntryOptions",function(){return oe}),r.d(t,"CollectionResourceOptionsInterface",function(){return se}),r.d(t,"CollectionResourceOptions",function(){return ce}),r.d(t,"CollectionEntry",function(){return ue}),r.d(t,"CollectionResource",function(){return le}),r.d(t,"CollectionViewResource",function(){return pe}),r.d(t,"CollectionEditResource",function(){return de}),r.d(t,"Template",function(){return me}),r.d(t,"ApiFormatter",function(){return x}),r.d(t,"ApiRequestService",function(){return j}),r.d(t,"ApiResponseProcessor",function(){return k}),r.d(t,"BatchStatus",function(){return H}),r.d(t,"ChangesCompilation",function(){return P}),r.d(t,"ChangesProcessor",function(){return _}),r.d(t,"CollectionCache",function(){return N}),r.d(t,"CollectionEntryService",function(){return ye}),r.d(t,"CollectionHandler",function(){return ve}),r.d(t,"CollectionMatcher",function(){return ge}),r.d(t,"CollectionResourceService",function(){return Ce}),r.d(t,"ColumnCache",function(){return Ie}),r.d(t,"ColumnExpansion",function(){return Se}),r.d(t,"ColumnHandler",function(){return Re}),r.d(t,"ColumnInfo",function(){return Fe}),r.d(t,"ColumnSet",function(){return be}),r.d(t,"ColumnSubsetCache",function(){return Oe}),r.d(t,"ColumnUtil",function(){return we}),r.d(t,"CreateRequest",function(){return Me}),r.d(t,"ItemAdministrator",function(){return Le}),r.d(t,"ItemCache",function(){return Te}),r.d(t,"ItemEntryService",function(){return xe}),r.d(t,"ItemHandler",function(){return je}),r.d(t,"ItemRequestService",function(){return ke}),r.d(t,"KeyService",function(){return De}),r.d(t,"LocalCache",function(){return He}),r.d(t,"LockService",function(){return Pe}),r.d(t,"ModuleChangesCompilation",function(){return Ve}),r.d(t,"QueryMatcher",function(){return Ne}),r.d(t,"QueryParser",function(){return Ue}),r.d(t,"QueryService",function(){return Qe}),r.d(t,"RequestColumnExpansion",function(){return Ye}),r.d(t,"SocketMessageHandler",function(){return Xe}),r.d(t,"instantiateOptions",function(){return o}),r.d(t,"shallowMerge",function(){return i}),r.d(t,"hasProperties",function(){return s}),r.d(t,"getFirstProperty",function(){return c}),r.d(t,"inArray",function(){return a}),r.d(t,"filterArray",function(){return u}),r.d(t,"emptyArray",function(){return l}),r.d(t,"pathExists",function(){return h}),r.d(t,"createPath",function(){return p}),r.d(t,"getPath",function(){return f}),r.d(t,"extend",function(){return m}),r.d(t,"merge",function(){return y}),r.d(t,"isObject",function(){return v}),r.d(t,"isBlankObject",function(){return g}),r.d(t,"isString",function(){return C}),r.d(t,"isNumber",function(){return I}),r.d(t,"isDate",function(){return S}),r.d(t,"isArray",function(){return R}),r.d(t,"isFunction",function(){return F}),r.d(t,"isRegExp",function(){return E}),r.d(t,"isBoolean",function(){return q}),r.d(t,"isElement",function(){return b}),r.d(t,"isWindow",function(){return O}),r.d(t,"isDefined",function(){return w}),r.d(t,"equals",function(){return M}),r.d(t,"copy",function(){return L}),r.d(t,"ApiResponseProcessorFactory",function(){return Je}),r.d(t,"BatchStatusFactory",function(){return We}),r.d(t,"ChangesCompilationFactory",function(){return Ke}),r.d(t,"ChangesProcessorFactory",function(){return ze}),r.d(t,"CollectionCacheFactory",function(){return Ge}),r.d(t,"CollectionEntryFactory",function(){return Ze}),r.d(t,"CollectionMatcherFactory",function(){return $e}),r.d(t,"CollectionResourceFactory",function(){return et}),r.d(t,"ColumnExpansionFactory",function(){return tt}),r.d(t,"ColumnInfoFactory",function(){return rt}),r.d(t,"ColumnSetFactory",function(){return nt}),r.d(t,"ColumnSubsetCacheFactory",function(){return ot}),r.d(t,"CreateRequestFactory",function(){return it}),r.d(t,"ItemCacheFactory",function(){return st}),r.d(t,"ItemEntryFactory",function(){return ct}),r.d(t,"ItemResourceFactory",function(){return at}),r.d(t,"LocalCacheFactory",function(){return ut}),r.d(t,"ModuleChangesCompilationFactory",function(){return lt}),r.d(t,"QueryMatcherFactory",function(){return ht}),r.d(t,"QueryParserFactory",function(){return pt}),r.d(t,"RequestColumnExpansionFactory",function(){return ft}),r.d(t,"TemplateFactory",function(){return dt}),r.d(t,"LocalCacheCallbackCondition",function(){return B})}])});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("moment")):"function"==typeof define&&define.amd?define(["moment"],t):"object"==typeof exports?exports.RmCore=t(require("moment")):e.RmCore=t(e.moment)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.r(t);var n=r(0);function o(e,t){for(var r in t)r in e&&void 0!==t[r]&&(e[r]=t[r])}function i(e,t){if(void 0===e)return t;var r={};for(var n in t)r[n]=void 0===e[n]?t[n]:e[n];return r}function s(e){for(var t in e)return!0;return!1}function c(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function a(e,t){for(var r=0,n=t;r<n.length;r++){if(e==n[r])return!0}return!1}function u(e,t){for(var r=[],n=0,o=e;n<o.length;n++){var i=o[n];t(i)&&r.push(i)}if(r.length===e.length)return!1;l(e);for(var s=0,c=r;s<c.length;s++){var a=c[s];e.push(a)}return!0}function l(e){e.splice(0)}function h(e,t){if(void 0===e)return!1;for(var r=0,n=t;r<n.length;r++){var o=n[r];if(void 0===e[o])return!1;e=e[o]}return!0}function p(e,t,r){for(var n=0;n<t.length;n++){var o=t[n];void 0===e[o]&&(e[o]=r[n]),e=e[o]}return e}function f(e,t,r){if(void 0===r&&(r=!1),void 0!==e){for(var n=0,o=t;n<o.length;n++){if(void 0===(e=e[o[n]])&&!r)return}return e}}function d(e,t,r){for(var n=0,o=t.length;n<o;++n){var i=t[n];if(v(i)||F(i))for(var s=Object.keys(i),c=0,a=s.length;c<a;c++){var u=s[c],l=i[u];r&&v(l)?S(l)?e[u]=new Date(l.valueOf()):E(l)?e[u]=new RegExp(l):l.nodeName?e[u]=l.cloneNode(!0):b(l)?e[u]=l.clone():(v(e[u])||(e[u]=R(l)?[]:{}),d(e[u],[l],!0)):e[u]=l}}return e}function m(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return d(e,t,!1)}function y(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return d(e,t,!0)}function v(e){return null!==e&&"object"==typeof e}function g(e){return null!==e&&"object"==typeof e&&!Object.getPrototypeOf(e)}function C(e){return"string"==typeof e}function I(e){return"number"==typeof e}function S(e){return"[object Date]"===toString.call(e)}var R=Array.isArray;function F(e){return"function"==typeof e}function E(e){return"[object RegExp]"===toString.call(e)}function q(e){return"boolean"==typeof e}function b(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function O(e){return e&&e.window===e}function w(e){return void 0!==e}function M(e,t){if(e===t)return!0;if(null===e||null===t)return!1;if(e!=e&&t!=t)return!0;var r,n,o,i,s,c=typeof e;if(c===typeof t&&"object"===c){if(!R(e)){if(S(e))return!!S(t)&&(i=e.getTime(),s=t.getTime(),i===s||i!=i&&s!=s);if(E(e))return!!E(t)&&e.toString()===t.toString();if(O(e)||O(t)||R(t)||S(t)||E(t))return!1;for(n in o=Object.create(null),e)if(!F(e[n])){if(!M(e[n],t[n]))return!1;o[n]=!0}for(n in t)if(!(n in o)&&w(t[n])&&!F(t[n]))return!1;return!0}if(!R(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!M(e[n],t[n]))return!1;return!0}}return!1}function L(e,t,r){var n=[],o=[];if(r=function(e){return I(e)&&e>0}(r)?r:NaN,t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(R(t))t.length=0;else for(var i in t)delete t[i];return n.push(e),o.push(t),s(e,t,r)}return c(e,r);function s(e,t,r){if(--r<0)return"...";if(R(e))for(var n=0,o=e.length;n<o;n++)t.push(c(e[n],r));else if(g(e))for(var i in e)t[i]=c(e[i],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var i in e)e.hasOwnProperty(i)&&(t[i]=c(e[i],r));else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=c(e[i],r));return t}function c(e,t){if(void 0===t&&(t=5),!v(e))return e;var r=n.indexOf(e);if(-1!==r)return o[r];if(O(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var i=!1,a=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(c(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case"[object Boolean]":case"[object Number]":case"[object String]":case"[object Date]":return new e.constructor(e.valueOf());case"[object RegExp]":var r=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return r.lastIndex=e.lastIndex,r;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(F(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===a&&(a=R(e)?[]:Object.create(Object.getPrototypeOf(e)),i=!0),n.push(e),o.push(a),i?s(e,a,t):a}}var T,x=function(){function e(){this.MOMENT_INVALID="Invalid date",this.SERVER_DATETIME_FORMAT="YYYY-MM-DD[T]HH:mm:ssZ",this.SERVER_TIME_FORMAT="HH:mm:ss",this.SERVER_DATE_FORMAT="YYYY-MM-DD"}return e.prototype.formatResponse=function(e,t){for(var r=0,n=t;r<n.length;r++){var o=n[r];e[o.path]=this.formatResponseValue(o.apiColumn.type,e[o.path])}return e},e.prototype.expandResponse=function(e,t,r){for(var n=0,o=r;n<o.length;n++){var i=o[n];e[i.path]=this.formatResponseValue(i.apiColumn.type,t[i.path])}return e},e.prototype.formatRequest=function(e,t,r){for(var n={},o=0,i=r;o<i.length;o++){var s=i[o],c=s.id,a=s.apiColumn,u=a.type;a.readOnly||(this.compareFields(u,e[c],t[c])||(n[c]=this.formatRequestValue(u,t[c])))}return n},e.prototype.formatRequestLocal=function(e,t){for(var r={},n=0,o=t;n<o.length;n++){var i=o[n],s=i.id,c=i.apiColumn;c.readOnly||(r[s]=this.formatRequestValue(c.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r){for(var n=0,o=r;n<o.length;n++){var i=o[n],s=i.id,c=i.apiColumn;if(!c.readOnly&&!this.compareFields(c.type,e[s],t[s]))return!0}return!1},e.prototype.getChanges=function(e,t,r){for(var n=[],o=0,i=r;o<i.length;o++){var s=i[o],c=s.id,a=s.apiColumn;a.readOnly||(this.compareFields(a.type,e[c],t[c])||n.push({oldValue:e[c],newValue:t[c],column:s.apiColumn}))}return n},e.prototype.copyFields=function(e,t,r){for(var n=0,o=r;n<o.length;n++){var i=o[n],s=i.path;t[s]=this.clone(i.apiColumn.type,e[s])}return t},e.prototype.shallowCopyFields=function(e,t,r,n){for(var o=0,i=n;o<i.length;o++){var s=i[o],c=s.path;r[c]=void 0!==e[c]?e[c]:this.clone(s.apiColumn.type,t[c])}return r},e.prototype.setDefaultValues=function(e,t){for(var r=0,n=t;r<n.length;r++){var o=n[r];e[o.id]=this.getDefaultValue(o.apiColumn.type)}return e},e.prototype.compareFields=function(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return M(t,r)}},e.prototype.compareFloats=function(e,t){var r=Math.abs(e),n=Math.abs(t),o=Math.abs(e-t);return e===t||(0===e||0===t||o<Number.MIN_VALUE?o<1.19e-7*Number.MIN_VALUE:o/Math.min(r+n,Number.MAX_VALUE)<1.19e-7)},e.prototype.compareMomentObjects=function(e,t){return e.isValid()?!!t.isValid()&&e.isSame(t):!t.isValid()},e.prototype.compareDurations=function(e,t){return e.asMilliseconds()===t.asMilliseconds()},e.prototype.formatResponseValue=function(e,t){switch(e){case"datetime":case"date":return this.formatResponseDate(t);case"color":return this.formatResponseColor(t);case"duration":return this.formatResponseDuration(t);case"json":return"string"==typeof t&&""!==t?JSON.parse(t):t;case"number":return 0===t?null:t;case"filesize":return t/1e6;default:return t}},e.prototype.formatRequestValue=function(e,t){switch(e){case"datetime":return this.formatRequestDateTime(t);case"date":return this.formatRequestDate(t);case"color":return this.formatRequestColor(t);case"duration":return this.formatRequestDuration(t);case"number":return 0===t?null:t;default:return t}},e.prototype.formatResponseDate=function(e){return null===e?n.invalid():n(e)},e.prototype.formatResponseDuration=function(e){return n.duration(null===e?0:e,"seconds")},e.prototype.formatResponseColor=function(e){return"#"===e.charAt(0)?e:"#"+e},e.prototype.formatRequestDateTime=function(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null},e.prototype.formatRequestDate=function(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null},e.prototype.formatRequestDuration=function(e){return e.asSeconds()},e.prototype.formatRequestColor=function(e){return"#"===e.charAt(0)?e.substring(1):e},e.prototype.getDefaultValue=function(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return n.invalid();case"duration":return n.duration();case"text":case"longtext":return"";case"color":return"#000000";default:return""}},e.prototype.isDefaultValue=function(e,t){return this.compareFields(e,t,this.getDefaultValue(e))},e.prototype.clone=function(e,t){switch(e){case"duration":return this.cloneDuration(t);case"date":case"datetime":return n(t);case"json":return L(t);default:return t}},e.prototype.getCloneFunction=function(e){switch(e){case"duration":return this.cloneDuration;case"date":case"datetime":return this.cloneDate;default:return this.identity}},e.prototype.cloneDuration=function(e){return n.duration(e)},e.prototype.cloneDate=function(e){return e.clone()},e.prototype.identity=function(e){return e},e}(),j=function(){function e(e,t){this.externalApiRequestService=e,this.apiResponseProcessorFactory=t}return e.prototype.template=function(e,t){return this.processResponse(this.externalApiRequestService.template(e,t))},e.prototype.create=function(e,t,r,n,o){return this.processResponse(this.externalApiRequestService.create(e,t,r,n,o))},e.prototype.delete=function(e,t){return this.processResponse(this.externalApiRequestService.delete(e,t))},e.prototype.updateItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.updateItems(e,t,r))},e.prototype.requestSkeleton=function(e,t){return this.processResponse(this.externalApiRequestService.requestSkeleton(e,t))},e.prototype.moveItems=function(e,t,r){return this.processResponse(this.externalApiRequestService.moveItems(e,t,r))},e.prototype.columns=function(e,t,r){return this.processResponse(this.externalApiRequestService.columns(e,t,r))},e.prototype.query=function(e,t,r,n){return this.processResponse(this.externalApiRequestService.query(e,t,r,n))},e.prototype.processResponse=function(e){var t=this;return e.then(function(e){return t.apiResponseProcessorFactory.construct(e)})},e}(),k=function(){function e(e,t){this.apiFormatter=e,this.response=t,this.columnIndexMap={},this.columnMap={},this.columns=t.columns,this.items=t.items,this.links=t.links,this.cacheable=t.cacheable,this.map=t.map,this.createColumnMaps()}return e.prototype.createColumnMaps=function(){for(var e in this.columns){this.columnIndexMap[e]={},this.columnMap[e]={};for(var t=0;t<this.columns[e].length;t++){var r=this.columns[e][t];this.columnIndexMap[e][r.id]=t,this.columnMap[e][r.id]=r}}},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t])return this.items[e][t].data[this.columnIndexMap[e][r]]},e.prototype.fetchDerivedObject=function(e,t,r){for(var n={},o=0,i=r;o<i.length;o++){var s=i[o];this.fetchDerivedValues(this.fetchValue(e,t,s.id),s,n)}return n},e.prototype.fetchDerivedValues=function(e,t,r){for(var n=0,o=t.children;n<o.length;n++){var i=o[n],s=void 0;null===e?(s=null,r[i.path]=this.apiFormatter.getDefaultValue(i.apiColumn.type)):(s=this.fetchValue(t.itemType,e,i.id),r[i.path]=s),i.isLeaf||this.fetchDerivedValues(s,i,r)}},e.prototype.fetchObject=function(e,t,r){if((void 0===r&&(r=!1),void 0!==this.items[e])&&void 0!==this.items[e][t]){for(var n=this.items[e][t].data,o={},i=0;i<n.length;i++)o[this.columns[e][i].id]=n[i];if(r){var s=this.items[e][t].links;for(var c in o.__links={},s)o.__links[c]=this.fetchObjectArray(c,r,s[c])}return o}},e.prototype.fetchObjectArray=function(e,t,r){var n=[];if(null===r){for(var o in this.items[e])n.push(this.fetchObject(e,o,t));return n}void 0===r&&(r=this.links[e]);for(var i=0,s=r;i<s.length;i++){o=s[i];n.push(this.fetchObject(e,o,t))}return n},e.prototype.fetchObjectMap=function(e,t,r,n){var o=this.columnIndexMap[e][t],i={},s=[];for(var c in this.items[e]){var a=this.items[e][c].data[o];s.push(a),i[a]=this.fetchObject(e,c,r)}return n?{result:i,keys:s}:i},e.prototype.fetchFieldMap=function(e,t){var r=this.columnIndexMap[e][t],n={};for(var o in this.items[e])n[o]=this.items[e][o].data[r];return n},e.prototype.fetchColumnArray=function(e){for(var t=[],r=0,n=this.columns[e];r<n.length;r++){var o=n[r];t.push(o)}return t},e.prototype.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchColumnsObject=function(){return this.columnMap},e.prototype.createResource=function(e,t){return{object:this.fetchObject(e,t),links:this.items[e][t].links}},e.prototype.hasItems=function(e){for(var t in this.items[e])return!0;return!1},e.prototype.getIdArray=function(e){var t=[];for(var r in this.items[e])t.push(r);return t},e}();!function(e){e.CACHED="cached",e.LOCAL="local",e.PROMISED="promised",e.EXPAND="expand",e.PROMISED_EXPAND="promised-expand",e.EXPAND_LOCAL="expand-local",e.PROMISED_EXPAND_LOCAL="promised-expand-local",e.RESOLVE="resolve",e.RESOLVE_VALUES="resolve-values"}(T||(T={}));var D,A=">",H=function(){function e(e,t,r,n){for(var o in this.promiseService=e,this.itemType=t,this.getItemId=r,this.getPromise=n,this.requestStatus=[T.RESOLVE,T.RESOLVE_VALUES,T.EXPAND,T.PROMISED_EXPAND],this.remoteExpandStatus=[T.EXPAND,T.PROMISED_EXPAND],this.localExpandStatus=[T.EXPAND_LOCAL,T.PROMISED_EXPAND_LOCAL],this.entries={},T)this.entries[T[o]]=[]}return e.prototype.add=function(e){this.entries[e.status].push(e.entry)},e.prototype.hasEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.entries[n].length>0)return!0}return!1},e.prototype.hasRequests=function(){return this.hasEntries(this.requestStatus)},e.prototype.forEachEntry=function(e,t){for(var r=0,n=e;r<n.length;r++)for(var o=n[r],i=0,s=this.entries[o];i<s.length;i++){var c=s[i];t(c,this.getItemId(c))}},e.prototype.reduceEntries=function(e,t,r){for(var n=0,o=e;n<o.length;n++)for(var i=o[n],s=0,c=this.entries[i];s<c.length;s++){var a=c[s];t(a,this.getItemId(a),r)}return r},e.prototype.reduceAllEntries=function(e,t){var r=this.entries;for(var n in r)for(var o=0,i=r[n];o<i.length;o++){var s=i[o];e(s,this.getItemId(s),t)}return t},e.prototype.getPromises=function(){var e=this;return this.promiseService.all(this.reduceEntries([T.PROMISED,T.PROMISED_EXPAND],function(t,r,n){n.push(e.getPromise(t))},[]))},e.prototype.getItemIds=function(e){return this.reduceEntries(e,function(e,t,r){r.push(t)},[])},e.prototype.getRequestIds=function(){return this.getItemIds(this.requestStatus)},e.prototype.getArray=function(e){var t=function(e,t,r){r.push(e)};return void 0===e?this.reduceAllEntries(t,[]):this.reduceEntries(e,t,[])},e.prototype.getMap=function(){return this.reduceAllEntries(function(e,t,r){r[t]=e},{})},e}(),P=function(){function e(e,t,r,n){this.collectionCacheFactory=e,this.keyService=t,this.singleItems=r,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.collections=this.collectionCacheFactory.construct(),this.processSingleItems(),this.processCollections(n),this.postProcess()}return e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e){this.moveArray.push(e)},e.prototype.addDeleteEntry=function(e,t){p(this.deleteMap,[e.itemType,e.itemId],[{},{item:e,parent:t}])},e.prototype.addUpdateEntry=function(e){p(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=e.parent;null===t&&(t=this.getDefaultParent()),p(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])},e.prototype.containsCreateEntry=function(e,t){var r=this.compilation.create;for(var n in r)for(var o in r[n]){var i=r[n][o][e];if(void 0!==i)for(var s in i)if(i[s].itemId===t)return!0}return!1},e.prototype.createDeleteCompilation=function(){var e=this.deleteMap,t=this.compilation.delete;for(var r in e)for(var n in e[r]){var o=e[r][n].item;void 0===t[r]&&(t[r]=[]),t[r].push(o)}},e.prototype.postProcess=function(){for(var e=this.deleteMap,t=0,r=this.moveArray;t<r.length;t++){var n=r[t],o=f(e,[n.itemType,n.itemId]);if(void 0!==o){var i=n.parent,s=i.itemType,c=i.itemId;!this.keyService.isLocalId(c)||this.containsCreateEntry(s,c)?(p(this.compilation.move,[s,c],[{},[]]).push(o),delete e[n.itemType][n.itemId]):n.parent=o.parent}}this.createDeleteCompilation()},e.prototype.processSingleItems=function(){for(var e=0,t=this.singleItems;e<t.length;e++){var r=t[e];r.isLocal()?this.addCreateEntry(r):r.hasChanges()&&this.addUpdateEntry(r)}},e.prototype.processCollections=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.collections.add(n),!n.isDeferred()){var o=void 0,i=void 0;n.isLocal()?(o=n.items,i=[]):n.hasEditResources?(o=n.getAddedItems(),i=n.getRemovedItems()):(o=[],i=[]);for(var s=0,c=o;s<c.length;s++){var a=c[s];a.isLocal()?this.addCreateEntry(a):this.addMoveEntry(a)}for(var u=0,l=i;u<l.length;u++){var h=l[u];this.addDeleteEntry(h,n.parent)}if(n.hasItemEditResources)for(var p=0,f=n.getUpdatedItems();p<f.length;p++){var d=f[p];this.addUpdateEntry(d)}}}},e}(),_=function(){function e(e,t,r,n,o,i,s,c,a,u,l){this.apiFormatter=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.collectionEntryService=n,this.collectionHandler=o,this.columnExpansionFactory=i,this.createRequestFactory=s,this.errorHandler=c,this.itemHandler=a,this.promiseService=u,this.requestColumnExpansionFactory=l}return e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var o=n[r].item,i=o.itemType;void 0===t[i]&&(t[i]=[]),t[i].push(o.itemId)}return t},e.prototype.getMapValue=function(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e,t,r,n,o){for(var i=[],s=0,c=this.createRequestFactory.construct(e.compilation.create,e.collections,t,n).run();s<c.length;s++){var a=c[s];i.push(this.executeCreateRequest(a,r).then(u))}return this.promiseService.all(i).then(function(){return r},this.errorHandler.reject);function u(e){return void 0!==o&&o(r),e}},e.prototype.executeCreateRequest=function(e,t){var r=this;return this.apiRequestService.requestSkeleton(e.request).then(function(n){var o=n.map,i=n.fetchColumnsObject(),s=e.items;for(var c in s){var a=r.columnExpansionFactory.construct(c,e.request.columns[c],i);for(var u in s[c]){var l=s[c][u],h=r.getMapValue(c,u,o);if(void 0!==h){var p=n.fetchObject(c,h),f=a.run(l.columns);l.itemId=h,l.updateFields(p,n.fetchDerivedObject(c,h,l.columns.root)),null!==f&&l.expand(p,n.fetchDerivedObject(c,h,f.difference.root),f),r.itemHandler.entries.add(l)}else console.warn("Create failed!",l)}}for(var c in e.collections.addToCollections(),o)for(var u in void 0===t[c]&&(t[c]={}),o[c])t[c][u]=o[c][u]},this.errorHandler.reject)},e.prototype.executeUpdateRequests=function(e,t){var r=[];for(var n in e)r.push(this.executeUpdateRequest(n,e[n],t));return this.promiseService.all(r)},e.prototype.executeUpdateRequest=function(e,t,r){var n=this,o={},i=this.requestColumnExpansionFactory.construct(),s=this.collectionHandler.getCollectionMatcher();for(var c in o[e]={},t){var a=t[c],u=o[e][c]={},l=f(r,[e,c]);u.values=a.formatRequest(),void 0!==l&&(u.parameters=l),i.expand(a.columns),s.expand(a)}for(var h=0,p=s.getCollectionsWithFittingItems();h<p.length;h++){var d=p[h];i.expand(d.columns)}return this.apiRequestService.updateItems(e,o,i.get()).then(function(r){var o=n.columnExpansionFactory.construct(e,i.get()[e],r.fetchColumnsObject());for(var c in t){var a=t[c],u=r.fetchObject(e,c);if(void 0!==u){var l=n.apiFormatter.copyFields(a.initial,{},a.columns.main);a.updateFields(u,r.fetchDerivedObject(e,c,a.columns.root)).callOnChange(l);var h=o.run(a.columns);null!==h&&a.expand(u,r.fetchDerivedObject(e,c,h.difference.root),h)}else console.warn("Update failed!",a)}s.removeFromAndAddToCollections()},this.errorHandler.reject)},e.prototype.executeDeleteRequests=function(e){var t=[];for(var r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeDeleteRequest=function(e,t){for(var r=this,n=[],o=0,i=t;o<i.length;o++){var s=i[o];n.push(s.itemId)}return this.apiRequestService.delete(e,n).then(function(e){for(var n=e.items,o=r.collectionHandler.getCollectionMatcher(),i=0,s=t;i<s.length;i++){var c=s[i];a(c.itemId,n)||console.warn("Delete failed!",c),o.expand(c)}o.removeFromCollections()},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e,t){var r=this,n=[];for(var o in e)for(var i in e[o])s(o,+i);return this.promiseService.all(n);function s(o,i){var s=e[o][i],c=r.getMapValue(o,i,t);n.push(r.apiRequestService.moveItems(o,void 0!==c?c:i,r.buildMoveRequest(s)).then(function(){r.processMoveResponse(s)},r.errorHandler.reject))}},e.prototype.processMoveResponse=function(e){for(var t=[],r={},n={},o=0,i=e;o<i.length;o++){var s=i[o],c=s.item;this.addCollectionMapEntry(r,s.parent.itemId,c,c.itemId),this.addCollectionMapEntry(n,c.parent.itemId,c,c),t.push(c)}this.forEachCollection(r,"removeItems"),this.forEachCollection(n,"addItems")},e.prototype.addCollectionMapEntry=function(e,t,r,n){p(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(n)},e.prototype.forEachCollection=function(e,t){for(var r in e)for(var n in e[r])for(var o in e[r][n]){var i=this.collectionHandler.entries.getByParent(r,n,o);null!==i&&i[t](e[r][n][o],null,!0)}},e.prototype.onItemsCreated=function(e,t,r){if(s(e)){for(var n=0,o=r;n<o.length;n++){var i=o[n],c=i.parent,a=i.getUpdatedItemColumns(e);if(null!==c)void 0!==(d=this.getMapValue(c.itemType,c.itemId,e))&&(c.itemId=d,i.query=this.collectionEntryService.createQuery(i.options),this.collectionHandler.entries.add(i));if(s(a)){void 0!==a.id&&i.onItemsCreated(e[i.itemType]);for(var u=0,l=i.items;u<l.length;u++){(f=l[u]).updateItemFields(e)}}}for(var h=0,p=t;h<p.length;h++){var f,d,m=(f=p[h]).parent;if(f.updateItemFields(e),null!==m)void 0!==(d=this.getMapValue(m.itemType,m.itemId,e))&&(m.itemId=d)}}},e.prototype.execute=function(e,t,r,n,o){var i=this;void 0===r&&(r={});var s=this.errorHandler,c=this.changesCompilationFactory.construct(e,t),a=c.compilation,u={};return this.executeCreateRequests(c,r,u,n,o).then(function(){return i.onItemsCreated(u,e,t),i.executeMoveRequests(a.move,u)},function(r){return i.onItemsCreated(u,e,t),s.reject(r)}).then(function(){return i.executeUpdateRequests(a.update,r)},s.reject).then(function(){return i.executeDeleteRequests(a.delete)},s.reject).then(function(){return u},s.reject)},e}();!function(e){e.MAYBE="maybe"}(D||(D={}));var V,B,N=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.contains=function(e){var t=this.entries[e.itemType];return void 0!==t&&void 0!==t[e.id]},e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.id]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):!!this.contains(e)&&delete this.entries[e.itemType][e.id]},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.matchParent=function(e,t,r){var n=e.parent;return null!==n&&(n.itemType===t&&n.itemId==r)},e.prototype.getByParent=function(e,t,r){var n=this.entries[r];if(void 0===n)return null;for(var o in n)if(this.matchParent(n[o],e,t))return n[o];return null},e.prototype.getResourceByParent=function(e,t,r){var n=this.getByParent(e,t,r);return null===n?null:n.getCurrentResource()},e.prototype.getCollectionsByParent=function(e,t){var r=this.entries,n=[];for(var o in r)for(var i in r[o]){var s=r[o][i];this.matchParent(s,e,t)&&n.push(s)}return n},e.prototype.getByContainingItem=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];void 0!==i.getItemById(t)&&n.push(i)}return n},e.prototype.getByFittingItem=function(e,t,r){var n=this.entries[e],o={fitting:[],notfitting:[],maybe:[]};if(void 0===n)return o;var i=this.queryMatcherFactory.construct(e,t,r);for(var s in n){var c=n[s],a=i.matchQuery(c.query.object);!0===a?o.fitting.push(c):a===D.MAYBE?o.maybe.push(c):o.notfitting.push(c)}return o},e.prototype.getByQuery=function(e,t){var r=this.entries[e];if(void 0===r)return null;for(var n in r){var o=r[n];if(o.query.string===t.string)return o}return null},e.prototype.getByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];i.options.entryKey===t&&n.push(i)}return n},e.prototype.getResourceByKey=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r)for(var i=0,s=r[o].resources;i<s.length;i++){var c=s[i];c.options.resourceKey===t&&n.push(c)}return n},e}(),U=(V=function(e,t){return(V=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}V(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),Q=function(){return function(){this.columns=!0,this.parent=null,this.templateOptions={},this.templateColumns={},this.deferRequest=!1,this.isDuplicate=!1}}(),Y=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return U(t,e),t}(Q),X=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),J=function(){return function(){this.edit=!1,this.onChange=yt,this.onDeactivate=yt}}(),W=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return X(t,e),t}(J),K=0,z=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++K,this.reloadQueued=!1,this.deferRequest=!1,this.parent=null,this.resources=[]}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},e.prototype.defer=function(e){return void 0===e&&(e=!1),this.deferred=this.factory.promiseService.defer(),this.deferRequest=e,this},e.prototype.resolve=function(){var e=this.deferred;return delete this.deferred,delete this.deferRequest,e.resolve(this),this},e.prototype.resolveDeferred=function(e,t,r){return this.columns=r,this.setFields(e,t),this.resolve()},e.prototype.isDeferred=function(){return void 0!==this.deferred},e.prototype.reject=function(e){return void 0===e&&(e=this.factory.itemEntryService.createUnfoundRemoteItemError()),this.deferred.reject(e),delete this.deferred,delete this.deferRequest,this},e.prototype.setFields=function(e,t){var r=this.factory.apiFormatter,n=this.columns.formatted;return this.initial=r.formatResponse(e,n.main),this.derived=r.formatResponse(t,n.derived),this},e.prototype.setLocalFields=function(e,t,r){void 0===r&&(r=this.columns);for(var n=this.factory,o=n.itemEntryService.getLocalDefaultValues(),i=0,s=r.main;i<s.length;i++){var c=s[i].id;o[c]=e[c]}return this.initial=n.apiFormatter.formatResponse(o,r.formatted.main),this.derived={"creator>displayname":n.authInterface.getUserDisplayname()},this.updateItemFields(t)},e.prototype.clone=function(e){void 0===e&&(e={});var t=this.factory,r=t.apiFormatter,n=t.itemEntryService,o=this.columns,i=this.parent,s=n.expandConversionMap(this,e),c=t.construct(s,r.copyFields(this.getFields(),{},o.main),r.copyFields(this.derived,{},o.derived),o);if(c.updateItemFields(e),c.modified=r.copyFields(c.initial,{},o.main),null===i)return c;var a=n.getConversionValue(i.itemType,i.itemId,e);return c.setParent(i.itemType,void 0===a?i.itemId:a),c},e.prototype.resetDerived=function(e){for(var t=this,r=[],n=0,o=this.columns.root;n<o.length;n++){var i=o[n];-1!==e.indexOf(i.id)&&r.push(i)}return function e(r){for(var n=0,o=r;n<o.length;n++){var i=o[n];i.isLeaf||e(i.children),delete t.derived[i.path]}}(r),this},e.prototype.clearResources=function(){return this.resources=[],this},e.prototype.deactivateResources=function(){for(var e=0,t=this.resources;e<t.length;e++){t[e].deactivate()}return this},e.prototype.getFields=function(){return void 0!==this.modified?this.modified:this.initial},e.prototype.expand=function(e,t,r){var n=this.factory.apiFormatter,o=r.difference;return this.columns=r.merged,n.expandResponse(this.initial,e,o.main),n.expandResponse(this.derived,t,o.derived),void 0===this.modified?this:(n.expandResponse(this.modified,e,o.main),this)},e.prototype.expandLocal=function(e){var t=e.difference.main;return this.columns=e.merged,0===t.length?this:(this.setLocalValues(this.initial,t),void 0===this.modified?this:(this.setLocalValues(this.modified,t),this))},e.prototype.setLocalValues=function(e,t){for(var r=this.factory,n=this.parent,o=0,i=t;o<i.length;o++){var s=i[o],c=s.id;if(void 0===e[c]){var a=s.apiColumn.type;e[c]="link"===a&&null!==n?n.itemId:r.apiFormatter.getDefaultValue(a)}}},e.prototype.updateFields=function(e,t,r){void 0===t&&(t=null),void 0===r&&(r=!0);var n=this.factory.apiFormatter,o=this.columns.main,i=this.initial,s=this.modified;if(void 0!==s)for(var c=0,a=o;c<a.length;c++){var u=(f=a[c]).id,l=f.apiColumn.type;(r||n.compareFields(l,i[u],s[u]))&&(s[u]=n.formatResponseValue(l,e[u]))}for(var h=0,p=o;h<p.length;h++){var f;i[u=(f=p[h]).id]=n.formatResponseValue(f.apiColumn.type,e[u])}return null!==t&&this.setDerived(t),this},e.prototype.updateItemValues=function(e,t,r){for(var n=this.factory.itemEntryService,o=this.parent,i=0,s=t;i<s.length;i++){var c=s[i],a=c.id,u=c.apiColumn,l=void 0;"link"===u.type&&void 0===e[a]?null!==o&&(l=o.itemId):l=n.getConversionValue(u.itemType,e[a],r),void 0!==l&&(e[a]=l)}},e.prototype.updateItemFields=function(e,t){void 0===t&&(t=this.columns);var r=t.item,n=this.modified;return this.updateItemValues(this.initial,r,e),void 0===n?this:(this.updateItemValues(n,r,e),this)},e.prototype.formatRequest=function(){var e=this.factory.apiFormatter,t=this.columns.main;return this.isLocal()?e.formatRequestLocal(this.getFields(),t):void 0===this.modified?{}:e.formatRequest(this.initial,this.modified,t)},e.prototype.setDisplayName=function(){if(void 0===this.modified)return this;var e=this.getDisplayName();return e&&(this.modified.displayname=e),this},e.prototype.getDisplayName=function(){var e=this.factory.itemEntryService,t=this.getFields();switch(this.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:e.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return e.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);case"Reparatie":return this.derived["materiaal>naam"];default:return t[e.getTitleField(this.itemType)]}},e.prototype.getChanges=function(e){return void 0===e&&(e=!1),void 0!==this.modified||e?this.factory.apiFormatter.getChanges(this.initial,e?{}:this.modified,this.columns.main):[]},e.prototype.isLocal=function(){return this.factory.keyService.isLocalId(this.itemId)},e.prototype.isLockable=function(){if(this.isLocal())return!1;switch(this.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}},e.prototype.hasChanges=function(){return void 0!==this.modified&&this.factory.apiFormatter.hasChanges(this.initial,this.modified,this.columns.main)},e.prototype.resetModified=function(){var e=this.columns.main;if(void 0===this.modified)return this;for(var t=0,r=e;t<r.length;t++){var n=r[t];this.modified[n.id]=this.factory.apiFormatter.clone(n.apiColumn.type,this.initial[n.id])}return this},e.prototype.setInitial=function(e,t){void 0===t&&(t=!1);var r,n=this.factory.apiFormatter;for(var o in e)this.initial[o]=e[o];if(void 0===this.modified)return t&&this.callOnChange(n.copyFields(this.initial,{},this.columns.main)),this;for(var o in r=n.copyFields(this.modified,{},this.columns.main),e)this.modified[o]=e[o];return t&&this.callOnChange(r),this},e.prototype.setModified=function(e){var t=this.factory,r=t.apiFormatter,n=this.columns,o=n.response[this.itemType];if(void 0===this.modified){var i=this.resources,s=this.initial,c=this.modified=this.isLocal()?t.itemEntryService.getLocalDefaultValues():{};if(void 0===e)r.copyFields(s,c,n.main);else for(var a in r.shallowCopyFields(e,s,c,n.main),e)void 0===o[a]&&(c[a]=e[a]);for(var u=0,l=i;u<l.length;u++){l[u].fields=c}return this}if(void 0===e)return this;for(var a in e)this.modified[a]=e[a];return this},e.prototype.setDerived=function(e){for(var t in e)this.derived[t]=e[t];return this},e.prototype.setParent=function(e,t){return this.parent={itemType:e,itemId:t},this},e.prototype.callOnChange=function(e){for(var t=0,r=this.resources.length;t<r;t++){var n=this.resources[t];null!==n&&n.options.onChange(n,e)}return this},e.prototype.toJSON=function(){return{id:this.id,parent:this.parent,initial:this.initial,modified:this.modified,derived:this.derived,columns:this.columns}},e}(),G=function(){function e(e,t,r){void 0===r&&(r=!1),this.entry=e,this.options=t,this._isNew=r,this.derived=e.derived,this.columns=e.columns.response[e.columns.itemType],e.resources.push(this)}return e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.clearResource=function(){var e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)},e.prototype.deactivate=function(){this.options.onDeactivate(this.entry)},e.prototype.toJSON=function(){var e=[];for(var t in this.columns)e.push(t);return{columns:e,fields:this.fields,derived:this.derived,entry:this.entry}},e}(),Z=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),$=function(e){function t(t,r,n){var o=e.call(this,t,r,n)||this;return o.fields=void 0===t.modified?t.initial:t.modified,o}return Z(t,e),t}(G),ee=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),te=function(e){function t(t,r,n,o){var i=e.call(this,r,n,o)||this;return i.factory=t,i.localCopies=[],i.transactions=0,r.setModified(),i.fields=r.modified,i}return ee(t,e),t.prototype.isNew=function(){return this._isNew&&0===this.transactions},t.prototype.start=function(){return void 0===this.localCopies&&(this.localCopies=[]),this.localCopies.push(this.copyFields()),this},t.prototype.rollback=function(){var e=this.entry;return this.factory.apiFormatter.copyFields(this.localCopies.pop(),e.modified,e.columns.main),this.isNew()&&0===this.localCopies.length&&this.deactivate(),this},t.prototype.commit=function(e){void 0===e&&(e=!0);var t=this.localCopies.pop();return e&&this.callOnChange(t),this.transactions++,this},t.prototype.getLocalCopy=function(){var e=this.localCopies;return void 0===e?null:0===e.length?null:e[e.length-1]},t.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(t.modified,e,t.columns.main)},t.prototype.setFields=function(e,t){void 0===t&&(t=!0);var r,n=this.columns,o=this.fields,i=!1;for(var s in t&&(r=this.copyFields()),e){var c=n[s];void 0!==c?this.factory.apiFormatter.compareFields(c.type,o[s],e[s])||(o[s]=e[s],i=!0):console.warn("setFields: no column found for",s)}return t&&i&&this.callOnChange(r),this},t.prototype.callOnChange=function(e){return this.entry.callOnChange(e),this},t.prototype.save=function(e){var t=this,r=this.factory,n=this.entry,o={};return void 0!==e&&p(o,[n.itemType,n.itemId],[{},e]),(n.isLockable()?r.lockService.fetchLock(n):r.promiseService.when()).then(function(){return r.changesProcessor.execute([n],[],o)},r.errorHandler.reject).then(function(){return t},r.errorHandler.reject)},t}(G),re=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ne=function(){return function(){this.columns=[],this.query=null,this.queryParams={},this.parent=null,this.deferRequest=!1,this.limit=null,this.entryKey=null}}(),oe=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return re(t,e),t}(ne),ie=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),se=function(){return function(){this.editItems=!1,this.editCollection=!1,this.modInstant=!1,this.enableSave=!0,this.onItemsCreated=yt,this.onChange=yt,this.onAdd=yt,this.onRemove=yt,this.onAddInitial=yt,this.onRemoveInitial=yt,this.resourceKey=null,this.clearOnTabChange=!0,this.clearOnSubTabChange=!0,this.custom=null}}(),ce=function(e){function t(t){var r=e.call(this)||this;return o(r,t),r}return ie(t,e),t}(se),ae=0,ue=function(){function e(e,t,r){this.factory=e,this.itemType=t,this.options=r,this.id=ae++,this.templateColumns=null,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.reloadQueued=!1,this.hasEditResources=!1,this.hasItemEditResources=!1,this.parent=r.parent,this.query=e.collectionEntryService.createQuery(r),this.columns=e.columnSetFactory.constructStub(t,r.columns),this.defer()}return e.prototype.defer=function(){return this.isDeferred()?this:(this.deferred=this.factory.promiseService.defer(),this.promise=this.deferred.promise,this)},e.prototype.isDeferred=function(){return void 0!==this.promise},e.prototype._resolve=function(){var e=this.deferred;return delete this.deferred,delete this.promise,e.resolve(this),this},e.prototype.resolve=function(e){var t=e.initial,r=e.modified;return this.columns=e.columns,this.initial=t,this.items=void 0!==r?r:t.slice(),this._resolve()},e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.factory.keyService.isLocalId(e.itemId)},e.prototype.matchParent=function(e,t){var r=this.parent;return null!==r&&(r.itemType===e&&r.itemId==t)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.getItemById=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(n.itemId===e)return n}},e.prototype.getIdArray=function(e){return void 0===e&&(e=[]),this.factory.collectionEntryService.getIdArray(this.items,e)},e.prototype.createItems=function(e){var t,r=this,n=this.factory,o=this.columns;return n.itemHandler.fetchTemplate(this.itemType).then(function(i){t=i;var s=[];null===r.templateColumns&&(r.templateColumns=t.columns.merge(o));for(var c=0,a=e;c<a.length;c++){var u=a[c];s.push(n.itemEntryFactory.constructLocal(n.keyService.getLocalId(),t,u,{},r.parent,r.templateColumns))}return s},n.errorHandler.reject)},e.prototype.resolveDerivedValues=function(e,t){return this.factory.itemHandler.resolveDerivedValues(e,this.columns.root,t)},e.prototype.addItems=function(e,t,r,n,o){if(void 0===r&&(r=!1),0===e.length)return[];var i=this.items,s=this.parent,c=this.columns.link,a=[],u=[];if(r)for(var l=this.initial,h=0,p=e;h<p.length;h++){var f=p[h];-1===l.indexOf(f)&&(l.push(f),a.push(f))}for(var d=0,m=e;d<m.length;d++){f=m[d];-1===i.indexOf(f)&&(null!==s&&(f.parent=s,null!==c&&void 0!==f.modified&&(f.modified[c.id]=s.itemId)),i.push(f),u.push(f))}return this.handleAddedItemCallbacks(a,u,t,n,o)},e.prototype.handleAddedItemCallbacks=function(e,t,r,n,o){void 0===r&&(r=null),void 0===n&&(n=!0),void 0===o&&(o=!0);var i=this.resources;if(e.length>0)for(var s=0,c=i;s<c.length;s++){(m=c[s]).options.onAddInitial(e,this)}if(0===t.length)return null===r?null:[];if(o&&i.length>0)for(var a=i[0].localCache,u=0,l=t;u<l.length;u++){var h=l[u];a.onActivateItem(h)}for(var p=null,f=0,d=i;f<d.length;f++){var m,y=(m=d[f]).addItemResources(t);m===r?(p=y,n&&m.callOnAdd(y)):m.callOnAdd(y)}return p},e.prototype.removeItems=function(e,t,r,n){return 0===e.length?[]:this.handleRemovedItems(function(t){return!a(t.itemId,e)},t,r,n)},e.prototype.clear=function(e,t,r){return this.handleRemovedItems(function(){return!1},e,t,r)},e.prototype.handleRemovedItems=function(e,t,r,n){void 0===r&&(r=!1);var o,i=this.factory.collectionEntryService,s=i.filterArray(this.items,e);if(r)o=i.filterArray(this.initial,e);else{for(var c=[],a=0,u=s;a<u.length;a++){var l=u[a];l.isLocal()&&c.push(l)}o=c.length>0?i.filterArray(this.initial,function(e){return-1===c.indexOf(e)}):[]}return this.handleRemovedItemCallbacks(o,s,t,n)},e.prototype.handleRemovedItemCallbacks=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=this.resources;if(e.length>0)for(var i=0,s=o;i<s.length;i++){(p=s[i]).options.onRemoveInitial(e,this)}if(0===t.length)return null===r?null:[];for(var c=null,a=0,u=t;a<u.length;a++){u[a].deactivateResources()}for(var l=0,h=o;l<h.length;l++){var p,f=(p=h[l]).removeItemResources(t);p===r?(c=f,n&&p.callOnRemove(f)):p.callOnRemove(f)}return c},e.prototype.createBatchStatus=function(e,t,r){return this.factory.itemHandler.createBatchStatus(this.itemType,e,this.parent,t,!1,r,!1).batchStatus},e.prototype.expandLocal=function(e,t){var r=this,n=this.factory,o=n.errorHandler,i=this.itemType;return n.columnHandler.fetch(i,e).then(function(s){var c=n.columnExpansionFactory.construct(i,e,s),a=r.createBatchStatus(r.getIdArray(),e,t);return a.getPromises().then(function(){return n.itemHandler.handleBatchResponse(a,t,e,null,s,c)},o.reject).then(function(){return c},o.reject)},o.reject)},e.prototype.expandRemote=function(e,t){var r=this,n=this.factory,o=n.errorHandler,i=this.itemType;return n.itemRequestService.requestItems(this,void 0,e).then(function(s){var c=s.items[i],a=s.fetchColumnsObject();r.handleRemovedItems(function(e){return void 0!==c[e.itemId]||e.isLocal()},null,!0,!0);var u=n.columnExpansionFactory.construct(i,e,a),l=r.createBatchStatus(s.links[i],e,t);return l.getPromises().then(function(){return n.itemHandler.handleBatchResponse(l,t,e,s,null,u)},o.reject).then(function(){return u},o.reject)},o.reject)},e.prototype.expand=function(e,t){var r=this;return!0!==e&&0===e.length?this.factory.promiseService.when(this):(this.isLocal()?this.expandLocal(e,t):this.expandRemote(e,t)).then(function(e){return r.expandColumns(e),r})},e.prototype.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.factory.collectionEntryService.createQuery(t))},e.prototype.extend=function(e,t,r,n){var o=this,i=this.factory,s=i.errorHandler,c=this.extendQuery(e).object,a=i.queryService.addAndCondition(c,i.queryService.createNotIn(this.getIdArray())),u=i.itemRequestService.requestItems(this,null!==this.options.limit?c:a).then(function(e){return i.itemRequestService.processResponse(e,e.links[o.itemType],o.parent,o.columns)},s.reject).then(function(e){return delete o.promise,o.addItems(e,t,n,r,!1)},s.reject);return this.promise=u.then(function(){return o},s.reject),u},e.prototype.queueReload=function(){this.reloadQueued=!0},e.prototype.expandColumns=function(e){var t=e.run(this.columns);null!==t&&(this.columns=t.merged,this.templateColumns=null,this.options.columns=this.columns.request)},e.prototype.expandRequestColumns=function(e){this.columns.expandRequestColumns(e),this.options.columns=this.columns.request},e.prototype.getAddedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=[],n=0,o=this.items;n<o.length;n++){var i=o[n];-1===t.indexOf(i)&&r.push(e?i.itemId:i)}return r},e.prototype.getRemovedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=this.items,n=[],o=0,i=t;o<i.length;o++){var s=i[o];-1===r.indexOf(s)&&n.push(e?s.itemId:s)}return n},e.prototype.getUpdatedItems=function(){for(var e=[],t=0,r=this.items;t<r.length;t++){var n=r[t];!n.isLocal()&&n.hasChanges()&&e.push(n)}return e},e.prototype.hasAddedItems=function(){return this.items.length>this.initial.length},e.prototype.hasRemovedItems=function(){return this.initial.length>this.items.length},e.prototype.hasUpdatedItems=function(){for(var e=0,t=this.items;e<t.length;e++){if(t[e].hasChanges())return!0}return!1},e.prototype.getCurrentResource=function(){var e=this.resources;return e[e.length-1]},e.prototype.clearResources=function(e){void 0===e&&(e=!1);for(var t=this.items,r=this.resources,n=[],o=0,i=t;o<i.length;o++){i[o].clearResources()}for(var s=0,c=r;s<c.length;s++){var a=c[s];if(!a.options[e?"clearOnSubTabChange":"clearOnTabChange"]){n.push(a);for(var u=0,l=a.items;u<l.length;u++){var h=l[u];h.entry.resources.push(h)}}}this.resources=n},e.prototype.revertChanges=function(){var e=this.getAddedItems(),t=this.getRemovedItems();this.items=this.initial.slice(),this.handleAddedItemCallbacks([],t),this.handleRemovedItemCallbacks([],e)},e.prototype.onItemsCreated=function(e){for(var t=0,r=this.resources;t<r.length;t++){var n=r[t];n.rebuildMap(),n.options.onItemsCreated(e)}},e.prototype.getUpdatedItemColumns=function(e){for(var t={},r=0,n=this.columns.item;r<n.length;r++){var o=n[r];void 0!==e[o.apiColumn.itemType]&&(t[o.id]=o)}return t},e.prototype.clone=function(e,t){for(var r=this.factory,n=r.itemEntryService.batchClone(this.items,t),o=0,i=n;o<i.length;o++){i[o].parent=e}return r.construct(this.itemType,r.collectionEntryService.cloneOptions(this.options,e)).resolve({columns:this.columns,initial:n})},e}(),le=function(){function e(e,t,r,n){this.itemResourceFactory=e,this.entry=t,this.options=r,this.localCache=n,this.itemIdMap={},this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}return e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.rebuildMap=function(){for(var e={},t=0,r=this.items;t<r.length;t++){var n=r[t];e[n.entry.itemId]=n}this.itemIdMap=e},e.prototype.addItemResources=function(e){var t=this;if(0===e.length)return[];for(var r=[],n=this.options,o=this.items,i=this.itemIdMap,s=this.itemResourceFactory.getConstructor({edit:n.editItems,onChange:n.onChange,onDeactivate:function(e){return t.localCache.onDeactivateItem(e)}}),c=0,a=e;c<a.length;c++){var u=a[c],l=u.itemId,h=void 0;void 0===i[l]?(h=s(u),o.push(h),i[l]=h):h=i[l],r.push(h)}return r},e.prototype.removeItemResources=function(e){var t=this,r=[];return u(this.items,function(n){for(var o=0,i=e;o<i.length;o++){var s=i[o];if(n.entry===s)return r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e){this.options.onAdd(e,this)},e.prototype.callOnRemove=function(e){this.options.onRemove(e,this)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++){e(r[t])}},e.prototype.filter=function(e){for(var t=[],r=0,n=this.items;r<n.length;r++){var o=n[r];e(o)&&t.push(o)}return t},e.prototype.first=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(e(n))return n}return null},e.prototype.some=function(e){return null!==this.first(e)},e.prototype.groupBy=function(e){var t=this.items,r={};if("string"==typeof e)for(var n=0,o=t;n<o.length;n++){void 0===r[a=(c=o[n]).fields[e]]&&(r[a]=[]),r[a].push(c)}if("function"==typeof e)for(var i=0,s=t;i<s.length;i++){var c,a;null!==(a=e(c=s[i]))&&(void 0===r[a]&&(r[a]=[]),r[a].push(c))}return r},e.prototype.map=function(e){var t=this.items,r=t.length,n=new Array(r);if("string"==typeof e)for(var o=0;o<r;o++)n[o]=t[o].fields[e];if("function"==typeof e)for(o=0;o<r;o++)n[o]=e(t[o]);return n},e.prototype.reduce=function(e,t){for(var r=0,n=this.items;r<n.length;r++){t=e(n[r],t)}return t},e.prototype.extend=function(e,t,r){var n=this;return void 0===t&&(t=!1),this.entry.extend(e,this,r,!0).then(function(e){return t?n.items:e})},e.prototype.deactivate=function(){this.localCache.clearCollection(this)},e.prototype.clearResource=function(){var e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(var n=0,o=t;n<o.length;n++){o[n].clearResource()}},e}(),he=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),pe=function(e){function t(t,r,n,o){return e.call(this,t,r,n,o)||this}return he(t,e),t}(le),fe=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),de=function(e){function t(t,r,n,o){var i=e.call(this,t.itemResourceFactory,r,n,o)||this;return i.factory=t,i}return fe(t,e),t.prototype.save=function(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");var e=this.factory,t=this.entry,r=t.parent;return null!==r&&e.keyService.isLocalId(r.itemId)?e.promiseService.when():e.changesProcessorFactory.construct().execute([],[t])},t.prototype.moveItems=function(e,t,r){var n=this.entry,o=this.options;if(o.enableSave||o.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(n.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var i=n.removeItems(e,this,!1,r),s=[],c=0,a=i;c<a.length;c++){var u=a[c];s.push(u.entry)}return t.entry.addItems(s,t,!1,r),i},t.prototype.removeItems=function(e,t){var r=this;void 0===t&&(t=!0);var n=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(function(){return t&&r.callOnRemove(n),n}):(t&&this.callOnRemove(n),this.factory.promiseService.when(n))},t.prototype.removeItem=function(e,t){return this.removeItems([e],t).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.addItems=function(e,t,r){var n=this;void 0===t&&(t=!0);var o=this.factory,i=this.options.modInstant;return this.entry.createItems(e).then(function(e){return i?e:n.entry.resolveDerivedValues(e,n.localCache.items)}).then(function(e){var s=n.entry.addItems(e,n,!1,!1,r);return i?n.save().then(function(){return t&&n.callOnAdd(s),s},o.errorHandler.reject):(t&&n.callOnAdd(s),s)},o.errorHandler.reject)},t.prototype.addItem=function(e,t,r){return this.addItems([e],t,r).then(function(e){return e[0]},this.factory.errorHandler.reject)},t.prototype.clear=function(e){return this.entry.clear(this,!1,e)},t}(le),me=function(){return function(e,t,r,n){this.itemType=t,this.response=r,this.fields=r.fetchObject(t,r.links[t][0]),this.responseColumns=e.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),n).merged,this.columns=e.columnSetFactory.construct(t,!0,this.responseColumns)}}(),ye=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.cloneOptions=function(e,t){var r=new oe(e);return r.queryParams=this.cloneQueryParams(e.queryParams),r.parent=t,r},e.prototype.processOptions=function(e){return new oe(e)},e.prototype.cloneQueryParams=function(e){var t={};for(var r in e){var o=e[r],i=void 0;i=Array.isArray(o)?o.slice():n.isMoment(o)?o.clone():o,t[r]=i}return t},e.prototype.createQuery=function(e){var t,r=e.parent;if(null===r)t=e.query;else{var n={linkedTo:r.itemType,query:{id:"&parentId"}};e.queryParams.parentId=r.itemId,t=null===e.query?n:this.queryService.addAndCondition(e.query,n)}var o=this.queryParserFactory.construct(t,e.queryParams).parse();return{object:o[0],string:o[1]}},e.prototype.getIdArray=function(e,t){void 0===t&&(t=[]);for(var r=0,n=e;r<n.length;r++){var o=n[r];t.push(o.itemId)}return t},e.prototype.filterArray=function(e,t){for(var r=[],n=[],o=0,i=e;o<i.length;o++){var s=i[o];(t(s)?r:n).push(s)}if(0===n.length)return n;e.length=r.length;for(var c=0;c<e.length;c++)e[c]=r[c];return n},e}(),ve=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h,p,f){this.batchStatusFactory=e,this.collectionCacheFactory=t,this.collectionEntryFactory=r,this.collectionEntryService=n,this.collectionMatcherFactory=o,this.columnHandler=i,this.columnSetFactory=s,this.errorHandler=c,this.itemHandler=a,this.itemRequestService=u,this.keyService=l,this.promiseService=h,this.queryParserFactory=p,this.queryService=f,this.entries=this.collectionCacheFactory.construct()}return e.prototype.removeFromAndAddToCollections=function(e,t){for(var r in e){var n=e[r],o=n.collection;o.removeItems(n.notfitting,null,!0),o.addItems(n.fitting,null,!0),n.maybe.length>0&&o.extend(vt,null,!0,t)}},e.prototype.getCollectionMatcher=function(){return this.collectionMatcherFactory.construct([this.entries],!0,!0)},e.prototype.removeFromCollections=function(e,t,r){var n;for(var o in void 0===r&&(r=null),e){for(var i=e[o],s=i.fitting,c=i.maybe,a=i.collection,u=[],l=0,h=s;l<h.length;l++){var p=h[l];u.push(p.itemId)}for(var f=0,d=c;f<d.length;f++){var m=d[f];u.push(m)}null!==r&&a===r.entry?n=a.removeItems(u,r,t):a.removeItems(u,null,t)}return n},e.prototype.addToCollections=function(e,t,r){var n;for(var o in void 0===r&&(r=null),e){var i=e[o],s=i.collection;s.isDeferred()||(null!==r&&s===r.entry?n=s.addItems(i.fitting,r,t):s.addItems(i.fitting,null,t),t&&i.maybe.length>0&&s.extend(vt,null,!0,t))}return n},e.prototype.batchExpand=function(e,t,r,n){var o=this;if(0===n.length)return this.promiseService.when(r);var i=[],s=[];for(var c in r){var a=r[c].entry;a.defer(),i.push(a.parent.itemId),s=s.concat(a.items)}return this.itemRequestService.requestLinkItems(e,i,t,null,n).then(function(e){for(var c=o.itemRequestService.processExpansion(n,e,t,s),a=0,u=i;a<u.length;a++){var l=u[a],h=r[l].entry;h.expandColumns(c),h._resolve()}return r})},e.prototype.batchExtend=function(e,t,r,n,o,i){var c=this;if(void 0===i&&(i=!1),!s(o))return this.promiseService.when({});var a=[],u=[];for(var l in r.queryParams=n(r.queryParams),o){var h=o[l].entry;h.extendQuery(n),a.push(h.parent.itemId),u=u.concat(h.getIdArray())}return this.itemRequestService.requestLinkItems(e,a,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(u)),r.columns).then(function(n){return c.itemRequestService.processLinkResponse(n,e,a,t,r)},this.errorHandler.reject).then(function(e){for(var t={},r=0,n=a;r<n.length;r++){var s=n[r],c=o[s],u=c.entry.addItems(e.items[s],c);t[s]=i?c.items:u}return t},this.errorHandler.reject)},e.prototype.batchFetch=function(e,t,r,n,o,i,s){for(var c=this,a=this.errorHandler,u=this.batchStatusFactory.construct(r,function(e){return e.parent.itemId},function(e){return e.promise}),l=0,h=t;l<h.length;l++){var p=h[l];u.add(this.getEntryStatus(r,this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:p}),i,s))}return this.promiseService.all(u.getPromises()).then(function(){var i,s,l=u.getRequestIds();if(null===n.query)s=null;else{var h=c.queryParserFactory.construct(n.query,n.queryParams).parse();s={object:h[0],string:h[1]}}if(l.length>0)i=c.itemRequestService.requestLinkItems(e,l,r,null===s?null:s.object,n.columns).then(function(t){return c.itemRequestService.processLinkResponse(t,e,l,r,n)},a.reject);else{if(!u.hasEntries([T.LOCAL]))return u.getMap();i=c.columnHandler.fetch(r,n.columns).then(function(e){return{columns:c.columnSetFactory.construct(r,n.columns,e,!1)}},a.reject)}return i.then(function(n){var i=o.batchGetLocalByParent(e,t,r,s),l=[];for(var h in i)l=l.concat(i[h]);return c.expandLocalItemEntries(r,l,n.columns,o).then(function(){return c.handleBatchResponse(u,n,i)},a.reject)},a.reject)},a.reject)},e.prototype.handleBatchResponse=function(e,t,r){var n={};return e.forEachEntry([T.CACHED],function(e,t){n[t]=e}),e.forEachEntry([T.RESOLVE],function(e,o){var i=t.items[o];n[o]=e.resolve({initial:i,modified:i.concat(r[o]),columns:t.columns})}),e.forEachEntry(e.remoteExpandStatus,function(e,r){e.expandColumns(t.columnExpansion),n[r]=e._resolve()}),e.forEachEntry([T.LOCAL],function(e,o){n[o]=e.resolve({initial:r[o],columns:t.columns})}),n},e.prototype.fetch=function(e,t,r,n,o){var i=this.errorHandler,s=this.getEntryStatus(e,t,n,o),c=s.entry;switch(s.status){case T.CACHED:return this.promiseService.when(c);case T.PROMISED:return c.promise;case T.EXPAND:return c.expand(t.columns,r).then(function(){return c._resolve()},i.reject);case T.PROMISED_EXPAND:return c.promise.then(function(){return c.defer().expand(t.columns,r)},i.reject).then(function(){return c._resolve()},i.reject);case T.LOCAL:return this.resolveLocal(c,r);default:return this.resolveRemote(c,r)}},e.prototype.getCachedEntryStatus=function(e,t){return e.columns.isSupersetOf(t.columns)?e.isDeferred()?T.PROMISED:e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?T.CACHED:(e.defer(),T.RESOLVE)):T.CACHED:e.isDeferred()?T.PROMISED_EXPAND:(e.defer(),T.EXPAND)},e.prototype.getDeferredEntryStatus=function(e,t,r,n){var o;return t.deferRequest?null!==(o=n.getByQuery(e,r))?(o.expandRequestColumns(t.columns),{entry:o,isDeferred:!1}):(o=this.collectionEntryFactory.construct(e,t),{entry:n.add(o),isDeferred:!0}):{entry:o=this.collectionEntryFactory.construct(e,t),isDeferred:!1}},e.prototype.getEntryStatus=function(e,t,r,n){var o,i,s,c=this.collectionEntryService.createQuery(t);return this.isLocal(t)?null!==(s=r.getByQuery(e,c))?{entry:s,status:this.getCachedEntryStatus(s,t)}:(s=(o=this.getDeferredEntryStatus(e,t,c,n)).entry,o.isDeferred?{entry:s,status:T.PROMISED}:{entry:r.add(s),status:T.LOCAL}):null!==(s=this.entries.getByQuery(e,c))?{entry:r.add(s),status:this.getCachedEntryStatus(s,t)}:(s=(i=this.getDeferredEntryStatus(e,t,c,n)).entry,i.isDeferred?{entry:s,status:T.PROMISED}:(r.add(s),this.entries.add(s),{entry:s,status:T.RESOLVE}))},e.prototype.resolveLocal=function(e,t){var r=this,n=e.itemType,o=e.options.columns;return this.columnHandler.fetch(n,o).then(function(i){var s=r.columnSetFactory.construct(n,o,i,!1);return r.expandLocalItemEntries(n,t.getLocalByQuery(n,e.query),s,t).then(function(t){return e.resolve({initial:t,columns:s})},r.errorHandler.reject)},this.errorHandler.reject)},e.prototype.resolveRemote=function(e,t){var r,n=this,o=this.errorHandler,i=e.itemType;return this.itemRequestService.requestItems(e).then(function(t){return r=n.columnSetFactory.construct(i,e.options.columns,t.fetchColumnsObject()),n.itemRequestService.processResponse(t,t.links[i],e.parent,r)},o.reject).then(function(s){return n.expandLocalItemEntries(i,t.getLocalByQuery(i,e.query),r,t).then(function(t){return e.resolve({initial:s,modified:s.concat(t),columns:r})},o.reject)},o.reject)},e.prototype.isLocal=function(e){var t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)},e.prototype.expandLocalItemEntries=function(e,t,r,n){return this.itemHandler.expandLocalEntries(e,t,r.request,r.response,n)},e}(),ge=function(){function e(e,t,r,n){this.queryMatcherFactory=e,this.collectionCaches=t,this.updateInitial=r,this.callOnActivate=n,this.map={}}return e.prototype.expand=function(e){var t=this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent);return this._expand(e,function(e){return t.matchQuery(e.query.object)})},e.prototype._expand=function(e,t){for(var r=this.map,n=e.itemId,o=0,i=this.collectionCaches;o<i.length;o++)for(var s=0,c=i[o].getByItemType(e.itemType);s<c.length;s++){var a=c[s],u=a.id,l=void 0;void 0===r[u]&&(r[u]={collection:a,matches:{}}),void 0===(l=r[u].matches)[n]&&(l[n]={item:e,isMatch:t(a)})}return this},e.prototype.getCollectionsWithFittingItems=function(){var e=[];for(var t in this.map){var r=this.map[t];this.hasFittingItems(r.matches)&&e.push(r.collection)}return e},e.prototype.addToCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],o=n.collection,i=this.groupItemEntries(n.matches),s=i.fitting;o.isDeferred()||(null!==e&&o===e.entry?t=o.addItems(s,e,this.updateInitial,!0,this.callOnActivate):o.addItems(s,null,this.updateInitial,!0,this.callOnActivate),this.updateInitial&&i.maybe.length>0&&o.extend(vt,null,!0,this.updateInitial))}return t},e.prototype.removeFromCollections=function(e){void 0===e&&(e=null);var t=null;for(var r in this.map){var n=this.map[r],o=n.collection,i=this.groupItemIds(n.matches).fitting;null===e||o!==e.entry?t=o.removeItems(i,e,this.updateInitial):o.removeItems(i,null,this.updateInitial)}return t},e.prototype.removeFromAndAddToCollections=function(){for(var e in this.map){var t=this.map[e],r=t.collection,n=this.groupItemEntries(t.matches);r.removeItems(n.notFitting,null,this.updateInitial),r.addItems(n.fitting,null,this.updateInitial),n.maybe.length>0&&r.extend(vt,null,!0,this.updateInitial)}},e.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var o in e){var i=e[o],s=i.item,c=i.isMatch;!0===c?t.push(s):!1===c?r.push(s.itemId):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},e.prototype.groupItemIds=function(e){var t=[],r=[];for(var n in e){var o=e[n];(!1===o.isMatch?r:t).push(o.item.itemId)}return{fitting:t,notFitting:r}},e.prototype.hasFittingItems=function(e){for(var t in e)if(!0===e[t].isMatch)return!0;return!1},e}(),Ce=function(){function e(){}return e.prototype.processOptions=function(e){return new ce(e)},e.prototype.getIdArray=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var o=n[r];t.push(o.entry.itemId)}return t},e}(),Ie=function(){function e(e){this.columnUtil=e,this.cache={},this.allColumns={}}return e.prototype.setColumn=function(e,t){var r=this.cache;void 0===r[e]&&(r[e]={});var n=r[e],o=t.id;return void 0===n[o]&&(n[o]=t),n[o]},e.prototype.setColumns=function(e,t,r){var n={};for(var o in r){var i=r[o];for(var s in n[o]={},i)n[o][s]=this.setColumn(o,i[s])}return!0===t&&(this.allColumns[e]=!0),n},e.prototype.retrieve=function(e,t){if(!0===t)return this.containsAll(e)?{cached:this.getColumns(e),missing:[]}:{cached:{},missing:!0};var r={},n=[];return this.retrieveColumns(e,t,n,r),{cached:r,missing:n}},e.prototype.containsAll=function(e){return!0===this.allColumns[e]},e.prototype.getColumns=function(e){var t,r=this.cache;return(t={})[e]=void 0===r[e]?[]:r[e],t},e.prototype.retrieveColumns=function(e,t,r,n){this.retrieveColumn(e,"id",r,n);for(var o=0,i=t;o<i.length;o++){var s=i[o];this.retrieveColumn(e,s,r,n)}},e.prototype.retrieveColumn=function(e,t,r,n){var o,i=this.columnUtil.parseRequestColumn(t),s=this.getColumn(e,i.id);if(void 0!==s){if(void 0===n[e]&&(n[e]={}),n[e][i.id]=s,0!==i.children.length){var c=[];this.retrieveColumns(s.itemType,i.children,c,n),0!==c.length&&r.push(((o={})[i.id]=c,o))}}else r.push(t)},e.prototype.getColumn=function(e,t){var r=this.cache[e];if(void 0!==r)return r[t]},e}(),Se=function(){function e(e,t,r,n){if(this.columnInfoFactory=e,this.itemType=t,this.responseColumns=n,this.expansionMap={},this.expansionMapSize=0,!0===r)for(var o in this.requestColumnsTrue=!0,this.requestColumns=[],n[t])this.requestColumns.push(o);else this.requestColumnsTrue=!1,this.requestColumns=r}return e.prototype.run=function(e){var t=this.expansionMap,r=e.id;return void 0!==t[r]?t[r]:(this.expansionMapSize++,t[r]=e.isSupersetOf(this.requestColumns)?null:e.expand(this.requestColumns,this.requestColumnsTrue,this.responseColumns))},e.prototype.aggregateRootColumns=function(){var e=this.expansionMap;if(1===this.expansionMapSize){var t=e[c(e)];return null!==t?t.difference.root:[]}var r={};for(var n in e){var o=e[n];null!==o&&this.expandRootColumnMap(o.difference.root,r)}return this.processRootColumnMap(r,null)},e.prototype.expandRootColumnMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var o=n[r],i=o.id;void 0===t[i]&&(t[i]={apiColumn:o.apiColumn,children:{}}),this.expandRootColumnMap(o.children,t[i].children)}},e.prototype.processRootColumnMap=function(e,t){var r=[];for(var n in e){var o=e[n],i=this.columnInfoFactory.construct(o.apiColumn,t),s=this.processRootColumnMap(o.children,i);s.length>0&&i.setChildren(i.apiColumn.itemType,s),r.push(i)}return r},e}(),Re=function(){function e(e,t,r,n,o){this.apiRequestService=e,this.errorHandler=t,this.promiseService=r,this.cache=n,this.columnUtil=o}return e.prototype.setColumn=function(e,t){return this.cache.setColumn(e,t)},e.prototype.setColumns=function(e,t,r){return this.cache.setColumns(e,t,r)},e.prototype.fetchItemTypeTranslations=function(e){for(var t={},r=0,n=e;r<n.length;r++){var o=n[r];t[o]=this.fetch(o,["id"])}return this.promiseService.all(t).then(function(e){var t={};for(var r in e)t[r]=e[r][r].id.name;return t},this.errorHandler.reject)},e.prototype.request=function(e,t,r){var n,o=this;return void 0===r&&(r={filter:!1}),this.apiRequestService.columns(e,(n={},n[e]=t,n),r).then(function(r){return o.cache.setColumns(e,t,r.fetchColumnsObject())},this.errorHandler.reject)},e.prototype.fetch=function(e,t,r){var n=this,o=this.cache.retrieve(e,t);return!0!==o.missing&&0===o.missing.length?this.promiseService.when(o.cached):this.request(e,o.missing,r).then(function(e){return n.columnUtil.mergeResponseColumns(e,o.cached).merged})},e.prototype.fetchAll=function(e){return this.cache.containsAll(e)?this.promiseService.when(this.cache.getColumns(e)):this.request(e,!0)},e}(),Fe=function(){function e(e,t){void 0===t&&(t=null),this.apiColumn=e,this.parent=t,this.itemType=null,this.children=[],this.isLeaf=!0;var r=e.id;this.id=r,null===t?(this.level=0,this.path=r,this.tailPath=""):(this.level=t.level+1,this.path=t.path+A+r,this.tailPath=0===t.level?r:t.tailPath+A+r)}return e.prototype.setChildren=function(e,t){return this.itemType=e,this.children=t,this.isLeaf=!1,this},e}(),Ee={},qe=0,be=function(){function e(e,t,r,n,o,i){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r,this.columnSetFactory=n,this.itemType=o,this.request=i,this.id=++qe,this.response=Ee,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.requestColumnsTrue=this.requestColumnsIsTrue(this.request)}return e.prototype.toJSON=function(){var e=function(e){return e.map(function(e){return e.id})};return{main:e(this.main),derived:e(this.derived)}},e.prototype.resolve=function(e,t,r){return void 0===t&&(t=!0),void 0===r&&(r=!0),this.enableCaching=t,this.requestColumnsTrue?this.processResponseColumns(e):this.processRequestColumns(e,r),this},e.prototype.expandRequestColumns=function(e){var t=this.columnUtil.mergeRequestColumns(this.request,e).merged;this.request=t,this.requestColumnsTrue=!0===t},e.prototype.isSupersetOf=function(e){if(!0===e)return this.requestColumnsTrue;var t=this.columnUtil,r=this.request;if(!0===r)return!t.containsDerivedColumns(e);for(var n=0,o=e;n<o.length;n++){var i=o[n];if(!t.containsColumn(i,r))return!1}return!0},e.prototype.processResponseColumns=function(e){var t=this.itemType;for(var r in this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,e):e,e[t])this.main.push(this.getColumnInfo(r,t,[],null,e)),this.request.push(r)},e.prototype.requestColumnsIsTrue=function(e){return!0===e},e.prototype.processRequestColumns=function(e,t){var r=this.itemType,n=this.request;if(this.response={},!this.requestColumnsIsTrue(n)&&0!==n.length){for(var o=0,i=n;o<i.length;o++){var s=i[o];null!==(c=this.getRequestColumnInfo(s,r,null,e))&&(this.main.push(c),c.isLeaf||this.root.push(c))}var c;if(t&&void 0===this.response[r].id)null!==(c=this.getRequestColumnInfo("id",r,null,e))&&this.main.push(c)}},e.prototype.getRequestColumnInfo=function(e,t,r,n){var o,i=this.columnUtil.parseRequestColumn(e),s=i.id;if(void 0!==n[t]&&(o=n[t][s]),void 0===o)return console.warn("No api column for request column",s,"for itemType",t),null;this.enableCaching&&(o=this.columnHandler.setColumn(t,o));var c=this.response;return void 0===c[t]&&(c[t]={}),void 0===c[t][s]&&(c[t][s]=o),this.getColumnInfo(s,t,i.children,r,n)},e.prototype.getColumnInfo=function(e,t,r,n,o){var i=this.columnUtil,s=o[t][e],c=this.columnInfoFactory.construct(s,n),a=null!==n;if(a?this.derived.push(c):this[i.isItemColumn(s)?"item":"notItem"].push(c),i.isFormattedColumn(s)&&this.formatted[a?"derived":"main"].push(c),i.isFilteredColumn(s)&&this.filtered.push(c),i.isSearchableColumn(s)&&this.searchable.push(c),i.isCustomColumn(s)&&this.custom.push(c),"link"===s.type&&(this.link=c),0===r.length)return this.leaf.push(c),c;for(var u=[],l=0,h=r;l<h.length;l++){var p=h[l],f=this.getRequestColumnInfo(p,s.itemType,c,o);null!==f&&u.push(f)}return c.setChildren(s.itemType,u)},e.prototype.getColumnSetExpansion=function(e,t){return{request:this.columnUtil.mergeRequestColumns(this.request,e),response:this.columnUtil.mergeResponseColumns(this.response,t).merged}},e.prototype.getMergedColumnSet=function(e,t){var r=this.columnSetFactory.construct(this.itemType,e.request.merged,e.response);return r.requestColumnsTrue=this.requestColumnsTrue||t,r},e.prototype.merge=function(e){return this.getMergedColumnSet(this.getColumnSetExpansion(e.request,e.response),e.requestColumnsTrue)},e.prototype.expand=function(e,t,r){var n=this.getColumnSetExpansion(e,r);return{merged:this.getMergedColumnSet(n,t),difference:this.columnSetFactory.construct(this.itemType,n.request.difference,n.response,!1,!1)}},e}(),Oe=function(){function e(e){this.requestColumns=e,this.cache={}}return e.prototype.run=function(e){var t=this.cache,r=e.id;return void 0!==t[r]?t[r]:t[r]=e.isSupersetOf(this.requestColumns)},e}(),we=function(){function e(){}return e.prototype.getColumnPath=function(e,t){for(var r="",n="",o=0,i=e;o<i.length;o++){n+=r+i[o].id,r=A}return null!==t&&(n+=":"+t),n},e.prototype.getDateFormatOptions=function(e){var t=n(),r={"J-M-Y":t.format("DD-MM-YYYY"),"J-M":t.format("DD-MM"),"j+F+Y":t.format("D MMM YYYY"),"D+j+F+Y":t.format("dddd D MMM YYYY"),F:t.format("MMM"),f:t.format("MMMM"),D:t.format("dddd"),d:t.format("ddd")};return"datetime"===e&&m(r,{"J-M-Y+H:i":t.format("DD-MM-YYYY HH:mm"),"J-M+H:i":t.format("DD-MM HH:mm"),"j+F+Y+H:i":t.format("DD MMMM Y HH:mm"),"D+j+F+Y+H:i":t.format("dddd DD MMM Y HH:mm"),"H:i":t.format("HH:mm")}),r},e.prototype.isStringColumn=function(e){switch(e.type){case"email":case"phone":case"url":case"text":case"longtext":case"textreplace":return!0;default:return!1}},e.prototype.isFloatColumn=function(e){switch(e.type){case"double":case"volume":case"weight":case"distance":case"dimension":case"power":case"current":case"price":case"percentage":return!0;default:return!1}},e.prototype.isIntColumn=function(e){switch(e.type){case"int":case"number":case"quantity":return!0;default:return!1}},e.prototype.isNumberColumn=function(e){return this.isFloatColumn(e)||this.isIntColumn(e)},e.prototype.isCustomColumn=function(e){return"customfield"===e.fieldtype},e.prototype.isItemColumn=function(e,t){switch(void 0===t&&(t=!0),e.type){case"id":return t;case"item":case"child":case"sibling":case"link":return!0;default:return!1}},e.prototype.isDateColumn=function(e){switch(e.type){case"datetime":case"date":return!0;default:return!1}},e.prototype.isRenderedColumn=function(e){switch(e.type){case"datetime":case"date":case"duration":return!0;default:return!1}},e.prototype.isFilteredColumn=function(e){if("staffel"===e.id)return!0;if(void 0!==e.generator)return!0;switch(e.type){case"price":case"bool":case"enum":case"country":case"volume":case"weight":case"distance":case"dimension":case"quantity":case"email":case"url":case"datetime":case"date":case"time":case"duration":case"html":case"textreplace":case"longtext":case"percentage":return!0;default:return!1}},e.prototype.isFormattedColumn=function(e){switch(e.type){case"datetime":case"date":case"time":case"duration":case"color":case"json":case"number":case"filesize":return!0;default:return!1}},e.prototype.isSelectableColumn=function(e){switch(e.type){case"blob":case"coordinate":case"forceupdate":case"id":case"json":case"order":case"parentid":case"parenttype":case"password":case"token":return!1}return!0},e.prototype.hasLocationProperty=function(e,t){return 0!=(t&e.location)},e.prototype.isEditableColumn=function(e){if(e.readOnly)return!1;switch(e.type){case"date":case"datetime":case"duration":return!1}return!0},e.prototype.isSearchableColumn=function(e){switch(e.type){case"email":case"phone":case"text":case"longtext":case"html":return!0;default:return!1}},e.prototype.getDefaultWeight=function(e){switch(e.type){case"double":case"price":case"bool":case"int":case"percentage":case"color":case"number":case"power":case"current":return.5;case"url":case"enum":case"email":case"text":case"item":case"link":return 1.5;case"longtext":case"html":case"textreplace":return 2;case"date":case"datetime":case"time":case"duration":default:return 1}},e.prototype.getComparators=function(e){switch(e.type){case"dimension":case"weight":case"price":return["=",">","<"];case"date":case"datetime":case"time":case"duration":return[">","<"];default:return["=","!="]}},e.prototype.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findRequestColumn(r.id,t);if(-1===n)return!1;if(0===r.children.length)return!0;if("string"==typeof t[n])return!1;for(var o=0,i=r.children;o<i.length;o++){var s=i[o];if(!this.containsColumn(s,t[n][r.id]))return!1}return!0},e.prototype.containsDerivedColumns=function(e){for(var t in e)if(this.parseRequestColumn(t).children.length>0)return!0;return!1},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,o=t;n<o.length;n++){var i,s=o[n],c=this.parseRequestColumn(s),a=c.children,u=r[e];if(void 0===u)return!1;if(void 0===(i=u[c.id]))return!1;if(a.length>0&&!this.responseColumnsAvailable(i.itemType,a,r))return!1}return!0},e.prototype.copyRequestColumns=function(e){if(!0===e)return!0;for(var t=[],r=0,n=e;r<n.length;r++){var o=n[r];t.push(this.copyRequestColumn(o))}return t},e.prototype.copyRequestColumn=function(e){var t,r=this.parseRequestColumn(e);if(0===r.children.length)return r.id;for(var n=[],o=0,i=r.children;o<i.length;o++){var s=i[o];n.push(this.copyRequestColumn(s))}return(t={})[r.id]=n,t},e.prototype.mergeRequestColumns=function(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};for(var r=this.copyRequestColumns(e),n=[],o=0,i=t;o<i.length;o++){var s=i[o],c=this.mergeRequestColumn(s,r);null!==c&&n.push(c)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r,n,o=this.parseRequestColumn(e),i=this.findRequestColumn(o.id,t);if(-1===i)return t.push(e),e;if(0===o.children.length)return null;"string"==typeof t[i]&&(t[i]=((r={})[o.id]=[],r));for(var s=[],c=0,a=o.children;c<a.length;c++){var u=a[c],l=this.mergeRequestColumn(u,t[i][o.id]);null!==l&&s.push(l)}return 0===s.length?null:((n={})[o.id]=s,n)},e.prototype.getRequestColumnId=function(e){if("string"==typeof e)return e;var t;for(t in e);return t},e.prototype.parseRequestColumn=function(e){if("string"==typeof e)return{id:e,children:[]};var t;for(t in e);return{id:t,children:e[t]}},e.prototype.mergeResponseColumns=function(e,t){var r={},n={};for(var o in e)if(void 0!==t[o]){var i=this.mergeResponseColumnMap(e[o],t[o]);r[o]=i.merged,n[o]=i.difference}else r[o]=e[o];for(var o in t)void 0===e[o]&&(r[o]=t[o],n[o]=t[o]);return{merged:r,difference:n}},e.prototype.mergeResponseColumnMap=function(e,t){var r={},n={};for(var o in e)r[o]=e[o];for(var o in t)w(e[o])||(r[o]=t[o],n[o]=t[o]);return{merged:r,difference:n}},e.prototype.isLocalColumnId=function(e){return"__"===e.substring(0,2)},e.prototype.processConfigColumns=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var o=n[r];this.isLocalColumnId(o)||this.processConfigColumn(this.parseConfigColumn(o),t)}return t},e.prototype.parseConfigColumn=function(e){return e.split(":")[0].split(A)},e.prototype.processConfigColumn=function(e,t){var r,n,o=e[0],i=1===e.length,s=this.findRequestColumn(o,t);i?-1===s&&t.push(o):(-1===s?s=t.push(((r={})[o]=[],r))-1:"string"==typeof t[s]&&(t[s]=((n={})[o]=[],n)),this.processConfigColumn(e.slice(1),t[s][o]))},e.prototype.findRequestColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(this.getRequestColumnId(n)===e)return r}return-1},e}(),Me=function(){function e(e,t,r,n,o,i,s,c){void 0===c&&(c=!1),this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n,this.compilation=o,this.localCollectionCache=i,this.parameterMap=s,this.breakupByParent=c,this.requests=[]}return e.prototype.finalizeRequest=function(e){for(var t=e.collections.getCollectionsWithFittingItems(),r=e.columns,n=0,o=t;n<o.length;n++){var i=o[n];r.expand(i.columns)}return e.request.columns=r.get(),e},e.prototype.setRequestParent=function(e,t){var r=t.request;return"Void"!==e&&(r.parentType=e,r.parentId={},!0)},e.prototype.run=function(){var e=this.compilation;if(this.breakupByParent)for(var t in e){var r=e[t];for(var n in r)if(!this.keyService.isLocalId(n)){var o=this.initializeRequest();this.extendRequest(r[n],this.setRequestParent(t,o)?+n:null,o),this.requests.push(this.finalizeRequest(o))}}else for(var t in e){r=e[t],o=this.initializeRequest();var i=this.setRequestParent(t,o),s=!1;for(var n in r)this.keyService.isLocalId(n)||(this.extendRequest(r[n],i?+n:null,o),s=!0);s&&this.requests.push(this.finalizeRequest(o))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{},columns:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:this.collectionMatcherFactory.construct([this.localCollectionCache,this.collectionHandler.entries],!0,!1)}},e.prototype.extendRequest=function(e,t,r){var n=r.request,o=r.items;for(var i in e)for(var s in void 0===n.itemType&&(n.itemType=i),void 0===o[i]&&(o[i]={},n.items[i]={}),e[i]){var c=e[i][s],a=f(this.compilation,[i,s]),u=n.items[i][s]={},l=f(this.parameterMap,[i,s]),h=void 0;if(null!==t&&(n.parentId[s]=t),r.columns.expand(c.columns),r.collections.expand(c),o[i][s]=c,u.values=c.formatRequest(),u.parameters=l,void 0!==a){for(var p in h=u.links={},a)for(var d in h[p]=[],a[p])h[p].push(d);this.extendRequest(a,null,r)}}},e}(),Le=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.authInterface=t,this.collectionHandler=r,this.collectionMatcherFactory=n,this.columnSetFactory=o,this.errorHandler=i,this.itemHandler=s,this.itemRequestService=c,this.keyService=a,this.localCacheFactory=u,this.localCacheManager=l,this.moduleChangesCompilationFactory=h,this.promiseInterface=p,this.queryService=f}return e.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.collectionHandler.entries.forEach(function(e){return e.queueReload()})},e.prototype.getCollectionMatcher=function(e,t){void 0===t&&(t=!0);for(var r=this.getLocalCache(),n=this.collectionMatcherFactory.construct([r.collections],!1,!0),o=0,i=e;o<i.length;o++){var s=i[o];t&&r.items.add(s),n.expand(s)}return n},e.prototype.fetchTitle=function(e,t,r){return this.itemHandler.fetchTitle(e,t,r,this.getLocalCache().items)},e.prototype.getItemById=function(e,t,r,n){void 0===r&&(r={});var o=this.getLocalCache();return this.itemHandler.fetchItem(e,t,new Y(r),o.items).then(function(e){return o.createItemResource(e,r,n)},this.errorHandler.reject)},e.prototype.getItemsById=function(e,t,r){void 0===r&&(r={});var n=this.getLocalCache();return this.itemHandler.fetchItems(e,t,new Y(r),n.items).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getItemsByQuery=function(e,t,r){var n,o=this;void 0===r&&(r={});var i=this.getLocalCache(),s=new Y(r);return this.apiRequestService.query(e,this.queryService.addParentCondition(t,s.parent),(n={},n[e]=s.columns,n)).then(function(t){return o.itemRequestService.processResponse(t,t.links[e],s.parent,o.columnSetFactory.construct(e,s.columns,t.fetchColumnsObject()))},this.errorHandler.reject).then(function(e){return i.createItemResources(e,r)},this.errorHandler.reject)},e.prototype.getNewResource=function(e,t,r,n){var o=this;void 0===t&&(t={}),void 0===r&&(r=!1);var i=this.getLocalCache();return t.edit=!0,this.itemHandler.fetchNewItem(e,new Y(t),i.items).then(function(e){var s=i.createItemResource(e.main,t,n,!0),c=o.processLinkedItems(e.linked,t,!0);return r?{main:s,linked:c}:s},this.errorHandler.reject)},e.prototype.getDuplicateById=function(e,t,r,n,o){return void 0===r&&(r={}),r.isDuplicate=!0,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=t),this.getNewResource(e,r,n,o)},e.prototype.getItemByState=function(e,t,r,n){void 0===r&&(r={});var o=this.keyService.parseStateKey(t);if(null===o){var i=t;if(!this.keyService.isLocalId(i)||this.getLocalCache().items.contains(e,i))return this.getItemById(e,i,r,n)}else if("duplicate"===o.type)return this.getDuplicateById(e,o.itemId,r,!1,n);return this.getNewResource(e,r,!1,n)},e.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:new oe(t),resource:new ce(t)}}},e.prototype.getLinkCollectionsDef=function(e,t,r,n,o){return{itemType:r,linkType:e,linkIdArray:t,linkField:n,options:{entry:new oe(o),resource:new ce(o)}}},e.prototype.getCollection=function(e,t){var r=this.getLocalCache();return this.collectionHandler.fetch(e,new oe(t),r.items,r.collections,r.deferredCollections).then(function(e){return r.createCollectionResource(e,new ce(t))},this.errorHandler.reject)},e.prototype.getCollectionFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResource(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getLinkCollection=function(e,t,r,n){void 0===n&&(n={});var o=this.getLocalCache();return n.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,new oe(n),o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResource(e,n)},this.errorHandler.reject)},e.prototype.getLinkCollections=function(e,t,r,n){var o=this.getLocalCache();return this.collectionHandler.batchFetch(e,t,r,new oe(n),o.items,o.collections,o.deferredCollections).then(function(e){return o.createCollectionResources(e,n)},this.errorHandler.reject)},e.prototype.getLinkCollectionsFromDef=function(e){var t=this.getLocalCache();return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,t.items,t.collections,t.deferredCollections).then(function(r){return t.createCollectionResources(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getAllLinkCollections=function(e,t,r){var n=this;return this.apiRequestService.query(e,{},{}).then(function(o){return n.getLinkCollections(e,o.links[e],t,r)},this.errorHandler.reject)},e.prototype.cloneItem=function(e,t){return this.addSingleItem(e.entry.clone(),t,!1)},e.prototype.cloneCollection=function(e,t,r){var n=t.parent;return void 0===n&&(n=null),this.addCollection(e.entry.clone(n,r),t)},e.prototype.saveCurrentLocalCache=function(e,t,r,n){return this.getLocalCache().save(e,t,r,n)},e.prototype.getCurrentCollections=function(){return this.getLocalCache().collections},e.prototype.getCurrentItems=function(){return this.getLocalCache().items},e.prototype.getModuleChanges=function(e){if(void 0===e&&(e=this.getLocalCache()),void 0===e.rootItem)throw new Error("itemAdministrator: No root item for local cache "+e.id);return this.moduleChangesCompilationFactory.construct(e.rootItem,e.items,e.collections).process()},e.prototype.addSingleItem=function(e,t,r,n){return void 0===t&&(t={}),void 0===n&&(n=this.getLocalCache()),n.createItemResource(n.items.add(e),t,r)},e.prototype.addSingleItems=function(e,t){for(var r=this.getLocalCache(),n=[],o=0,i=e;o<i.length;o++){var s=i[o];n.push(this.addSingleItem(s,t,!1,r))}return n},e.prototype.addCollection=function(e,t){var r=this.getLocalCache();return r.collections.add(e),r.createCollectionResource(e,t)},e.prototype.createItemResources=function(e,t,r,n){for(var o=[],i=0,s=t;i<s.length;i++){var c=s[i];o.push(n.createItemResource(c,r)),"Projectnotitie"===e&&p(n.tabRequestParameters,[c.itemType,c.itemId],[{},{no_notification:!0}])}return o},e.prototype.processLinkedItems=function(e,t,r){void 0===r&&(r=!0);for(var n=this.getLocalCache(),o={},i=0,s=e;i<s.length;i++){o[(u=s[i]).itemType]=this.createItemResources(u.itemType,u.itemEntries,t,n)}if(!r)return o;for(var c=0,a=e;c<a.length;c++){var u=a[c];this.getCollectionMatcher(u.itemEntries,!1).addToCollections()}return o},e.prototype.expandProcessLinkedItems=function(e,t){for(var r=this.getLocalCache(),n=this.promiseInterface.when({}),o=0,i=e;o<i.length;o++){var s=i[o];n=n.then(this.constructOnItemsExpanded(s.itemType,s.itemEntries,t,r),this.errorHandler.reject)}return n},e.prototype.constructOnItemsExpanded=function(e,t,r,n){var o=this;return function(i){return o.expandAddToCollections(e,t,null,n).then(function(){return i[e]=o.createItemResources(e,t,r,n),i},o.errorHandler.reject)}},e.prototype.expandAddToCollections=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=this.getLocalCache());for(var o=this.collectionMatcherFactory.construct([n.collections],!1,!1),i=0,s=t;i<s.length;i++){var c=s[i];o.expand(c)}var a=this.getColumnSuperset(o.getCollectionsWithFittingItems());return null===a?this.promiseInterface.when(null===le?null:[]):this.itemHandler.expandLocalEntries(e,t,a.request,a.response,n.items).then(function(){return o.addToCollections(r)},this.errorHandler.reject)},e.prototype.getColumnSuperset=function(e){var t={};if(0===e.length)return null;for(var r=e[0].columns,n=1;n<e.length;n++){var o=e[n].columns;!0!==t[o.id]&&(t[o.id]=!0,r=r.merge(o))}return r},e.prototype.getLocalCache=function(){return this.localCacheManager.getCurrentLocalCache(this.authInterface.getUniqueUserId())},e.prototype.resetLocalCache=function(){var e=this.getLocalCache(),t=this.localCacheFactory.construct();e.clearResources(),this.localCacheManager.setCurrentLocalCache(this.authInterface.getUniqueUserId(),t)},e.prototype.addToCollections=function(e,t){return this.getCollectionMatcher(e).addToCollections(t)},e.prototype.removeFromCollections=function(e,t){return this.getCollectionMatcher(e,!1).removeFromCollections(t)},e.prototype.saveLocal=function(e){var t=e.entry;return t.setDisplayName(),this.addToCollections([t]),this.promiseInterface.when(e)},e.prototype.updateItemIdMap=function(e,t){if(void 0!==t)for(var r in t){var n=t[r];void 0!==e[r]&&(e[n]=e[r],delete e[r])}},e.prototype.createCollectionResource=function(e,t){return this.addCollection(e,t)},e.prototype.createItemResource=function(e,t,r){return this.addSingleItem(e,t,r)},e.prototype.onBeforeSave=function(e,t,r){return this.getLocalCache().onBeforeSave(e,t,r)},e.prototype.onSaveSuccess=function(e,t,r){return this.getLocalCache().onSaveSuccess(e,t,r)},e}(),Te=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.some=function(e){var t=this.entries;for(var r in t)for(var n in t[r])if(e(t[r][n]))return!0;return!1},e.prototype.getByItemType=function(e){var t=this.entries[e],r=[];if(void 0===t)return r;for(var n in t)r.push(t[n]);return r},e.prototype.getByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];i.isDeferred()||this.matchQuery(i,t)&&n.push(i)}return n},e.prototype.getLocalByQuery=function(e,t){var r=this.entries[e],n=[];if(void 0===r)return n;for(var o in r){var i=r[o];i.isLocal()&&(this.matchQuery(i,t)&&n.push(i))}return n},e.prototype.getByParent=function(e,t,r){var n=this.entries[r],o=[];if(void 0===n)return o;for(var i in n){var s=n[i],c=s.parent;null!==c&&(c.itemType===e&&c.itemId==t&&o.push(s))}return o},e.prototype.batchGetLocalByParent=function(e,t,r,n){for(var o=this.entries[r],i={},s=0,c=t;s<c.length;s++){i[c[s]]=[]}if(void 0===o)return i;for(var a in o){var u=o[a],l=u.parent;null!==l&&(l.itemType===e&&void 0!==i[l.itemId]&&u.isLocal()&&(null===n||this.matchQuery(u,n))&&i[l.itemId].push(u))}return i},e.prototype.forEach=function(e){var t=this.entries;for(var r in t)for(var n in t[r])e(t[r][n])},e.prototype.toArray=function(){var e=this.entries,t=[];for(var r in e)for(var n in e[r])t.push(e[r][n]);return t},e.prototype.add=function(e){var t=this.entries,r=e.itemType;return void 0===t[r]&&(t[r]={}),t[r][e.itemId]=e},e.prototype.get=function(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]},e.prototype.contains=function(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]},e.prototype.updateItemId=function(e,t){var r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]},e.prototype.matchQuery=function(e,t){return!0===this.queryMatcherFactory.construct(e.itemType,e.getFields(),e.parent).matchQuery(t.object)},e}(),xe=function(){function e(e,t){this.authInterface=e,this.keyService=t}return e.prototype.processOptions=function(e){return new Y(e)},e.prototype.createUnfoundRemoteItemError=function(){return{message:"The requested item could not be found / your current permissions are not sufficient"}},e.prototype.createUnfoundLocalItemError=function(e){return{message:"A local item of type "+e+" could not be found"}},e.prototype.createLocalConversionMap=function(e,t,r,n){void 0===r&&(r=!1);var o=n.links[e][0],i={};return i[e]={},i[e][o]=t,r&&this.expandLocalConversionMap(e,o,n,i),i},e.prototype.expandLocalConversionMap=function(e,t,r,n){var o=r.items[e][t].links;for(var i in o){var s=o[i];void 0===n[i]&&(n[i]={});for(var c=0,a=s;c<a.length;c++){var u=a[c];n[i][u]=this.keyService.getLocalId(),this.expandLocalConversionMap(i,u,r,n)}}},e.prototype.expandConversionMap=function(e,t,r){var n,o=e.itemType,i=e.itemId;return void 0===t[o]&&(t[o]={}),void 0!==(n=t[o])[i]?n[i]:(void 0===r&&(r=this.keyService.getLocalId()),n[i]=r)},e.prototype.batchExpandConversionMap=function(e,t){for(var r=0,n=e;r<n.length;r++){var o=n[r];this.expandConversionMap(o,t)}return t},e.prototype.getConversionValue=function(e,t,r){if(void 0!==r[e])return r[e][t]},e.prototype.batchClone=function(e,t){void 0===t&&(t={});var r=[];this.batchExpandConversionMap(e,t);for(var n=0,o=e;n<o.length;n++){var i=o[n];r.push(i.clone(t))}return r},e.prototype.getFullName=function(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)},e.prototype.getTitleField=function(e){switch(e){case"Exemplaar":return"serienummer";case"Factuur":return"nummer";case"Files":return"friendlyname";case"Functie":case"Standaardfunctie":return"naamintern";case"Voorraadmutatie":return"omschrijving";case"Barcode":return"code";case"Betaalmiddel":case"Betalingsconditie":case"Briefpapier":case"TaxClass":case"TaxSchema":case"Condition":case"Factuurmoment":case"Functiegroep":case"Grootboek":case"Inhuur":case"Inhuurgroep":case"Inhuurmateriaal":case"Materiaal":case"MateriaalCat":case"Medewerkertarief":case"Notitie":case"Planningmateriaal":case"Project":case"Staffelgroep":case"Subproject":case"Taak":case"Tag":case"Template":case"Tijd":case"Titel":case"Type":case"Voertuig":return"naam";default:return"displayname"}},e.prototype.getLocalDefaultValues=function(){return{permissions:"7",creator:this.authInterface.getUserId(),created:n()}},e.prototype.hasLocalDefaultValue=function(e){switch(e){case"permissions":case"creator":case"created":return!0;default:return!1}},e}(),je=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h,p,f,d){this.apiFormatter=e,this.apiRequestService=t,this.batchStatusFactory=r,this.columnExpansionFactory=n,this.columnHandler=o,this.columnSetFactory=i,this.columnSubsetCacheFactory=s,this.columnUtil=c,this.errorHandler=a,this.itemCacheFactory=u,this.itemEntryFactory=l,this.itemEntryService=h,this.keyService=p,this.promiseService=f,this.templateFactory=d,this.templates={},this.entries=this.itemCacheFactory.construct()}return e.prototype.fetchItem=function(e,t,r,n){var o=this.getEntryStatus(e,t,r.parent,r.deferRequest,n,!0,this.columnSubsetCacheFactory.construct(r.columns));return null===o?this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(e)):this.resolveCached(o.entry,o.status,r,n)},e.prototype.fetchNewItem=function(e,t,r){var n=this,o=r.add(this.itemEntryFactory.constructDeferred(e,t.isDuplicate?this.keyService.getLocalDuplicateId():this.keyService.getLocalId(),!0,!1));return this.fetchTemplate(e,t.templateOptions,t.templateColumns).then(function(e){return n.resolveLocal(o,t.parent,e,r)},function(e){return o.reject(e),n.errorHandler.reject(e)})},e.prototype.createBatchStatus=function(e,t,r,n,o,i,s){for(var c=this.columnSubsetCacheFactory.construct(n),a=this.batchStatusFactory.construct(e,function(e){return e.itemId},function(e){return e.deferred.promise}),u=!0,l=0,h=t;l<h.length;l++){var p=h[l],f=this.getEntryStatus(e,p,r,o,i,s,c);null!==f?a.add(f):u=!1}return{batchStatus:a,success:u}},e.prototype.fetchItems=function(e,t,r,n){var o,i,s=this,c=this.errorHandler,a=r.columns,u=this.createBatchStatus(e,t,r.parent,a,r.deferRequest,n,!0),l=u.batchStatus,h=u.success;return l.hasRequests()?i=(o=this.requestItems(e,l.getRequestIds(),a)).then(function(e){return e.fetchColumnsObject()},function(e){return l.forEachEntry([T.RESOLVE],function(e){return s.clearItem(e,n)}),c.reject(e)}):l.hasEntries(l.localExpandStatus)?(o=null,i=this.columnHandler.fetch(e,a)):(o=null,i=null),this.promiseService.all({entries:l.getPromises(),response:o,columns:i}).then(function(e){return s.handleBatchResponse(l,n,a,e.response,e.columns)},c.reject).then(function(e){return e&&h?l.getArray():c.reject()},c.reject)},e.prototype.handleBatchResponse=function(e,t,r,n,o,i){var s=this,c=e.itemType,a=[T.RESOLVE],u=!0;if(e.hasEntries(a)){var l=this.columnSetFactory.construct(c,r,o);e.forEachEntry(a,function(e){s.resolveRemote(e,l,n,t)||(u=!1)})}return e.forEachEntry([T.RESOLVE_VALUES],function(e){s.resolveRemoteValues(e,n)||(u=!1)}),e.hasEntries(e.remoteExpandStatus)&&(void 0===i&&(i=this.columnExpansionFactory.construct(c,r,o)),e.forEachEntry(e.remoteExpandStatus,function(e){return s.resolveExpansion(e,i,n)})),e.hasEntries(e.localExpandStatus)?this.expandLocalEntries(c,e.getArray(e.localExpandStatus),r,o,t).then(function(e){for(var t=0,r=e;t<r.length;t++){r[t].resolve()}return u},this.errorHandler.reject):this.promiseService.when(u)},e.prototype.resolveCached=function(e,t,r,n){var o,i=this,s=function(t){e.reject(t)};switch(t){case T.LOCAL:case T.CACHED:return this.promiseService.when(e);case T.PROMISED:return e.deferred.promise;case T.EXPAND:return o=this.getColumnDifference(e,r.columns),this.requestItem(e,o).then(function(t){i.resolveExpansion(e,i.columnExpansionFactory.construct(e.itemType,o,t.fetchColumnsObject()),t)},s),e.deferred.promise;case T.EXPAND_LOCAL:return o=this.getColumnDifference(e,r.columns),this.columnHandler.fetch(e.itemType,o).then(function(t){return i.expandLocalEntries(e.itemType,[e],o,t,n).then(function(){return e.resolve()},s)},s),e.deferred.promise;case T.PROMISED_EXPAND:case T.PROMISED_EXPAND_LOCAL:return e.deferred.promise.then(function(){return i.resolveCached(e,i.getCachedEntryStatus(e,i.columnSubsetCacheFactory.construct(r.columns)),r,n)},this.errorHandler.reject);case T.RESOLVE_VALUES:return this.requestItem(e).then(function(t){i.resolveRemoteValues(e,t)},function(t){e.reject(t)}),e.deferred.promise;case T.RESOLVE:return this.requestItem(e).then(function(t){i.resolveRemote(e,e.columns.resolve(t.fetchColumnsObject()),t,n)},function(t){i.clearItem(e,n),e.reject(t)}),e.deferred.promise}},e.prototype.getColumnDifference=function(e,t){return this.columnUtil.mergeRequestColumns(e.columns.request,t).difference},e.prototype.resolveLocal=function(e,t,r,n){var o=e.itemType,i=e.itemId,s=this.itemEntryService.createLocalConversionMap(o,i,!0,r.response);return e.columns=r.columns,null!==t&&e.setParent(t.itemType,t.itemId),e.setLocalFields(r.fields,s).resolve(),{main:e,linked:this.createLocalEntries(o,i,r,s,n)}},e.prototype.resolveExpansion=function(e,t,r){var n=e.itemType,o=e.itemId,i=t.run(e.columns);return null===i?e:(e.expand(r.fetchObject(n,o),r.fetchDerivedObject(n,o,i.difference.root),i),e.resolve())},e.prototype.clearItem=function(e,t){this.entries.clear(e),t.clear(e)},e.prototype.resolveRemote=function(e,t,r,n){var o=this.getResponseFields(e,t,r);return null===o?(this.clearItem(e,n),e.reject(),!1):(e.resolveDeferred(o.initial,o.derived,t),!0)},e.prototype.resolveRemoteValues=function(e,t){var r=this.getResponseFields(e,e.columns,t);return null===r?(e.reject(),!1):(e.updateFields(r.initial,r.derived,!1).resolve(),!0)},e.prototype.getResponseFields=function(e,t,r){var n=e.itemType,o=e.itemId,i=r.fetchObject(n,o);return void 0===i?null:{initial:i,derived:r.fetchDerivedObject(n,o,t.root)}},e.prototype.fetchTemplate=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r={});var o=s(t),i=c(r);if(!o){var a=this.templates[e];if(void 0!==a&&(null===i||this.columnUtil.responseColumnsAvailable(i,r[i],a.responseColumns)))return this.promiseService.when(a)}return this.promiseService.all({template:this.apiRequestService.template(e,t),additionalColumns:null===i?{}:this.columnHandler.fetch(i,r[i])}).then(function(t){var r=t.template,i=n.templateFactory.construct(e,r,t.additionalColumns);return!o&&r.cacheable&&(n.templates[e]=i),i},this.errorHandler.reject)},e.prototype.getEntryStatus=function(e,t,r,n,o,i,s){var c;return this.keyService.isLocalId(t)?void 0!==(c=o.get(e,t))?{entry:c,status:this.getCachedEntryStatus(c,s)}:null:void 0!==(c=this.entries.get(e,t))?{entry:i?o.add(c):c,status:this.getCachedEntryStatus(c,s)}:(c=this.itemEntryFactory.constructDeferred(e,t,s.requestColumns,n),null!==r&&c.setParent(r.itemType,r.itemId),i&&o.add(c),this.entries.add(c),{entry:c,status:n?T.PROMISED:T.RESOLVE})},e.prototype.getCachedEntryStatus=function(e,t){var r=e.columns;return e.isDeferred()?e.deferRequest?(r.expandRequestColumns(t.requestColumns),T.RESOLVE):t.run(r)?T.PROMISED:e.isLocal()?T.PROMISED_EXPAND_LOCAL:T.PROMISED_EXPAND:t.run(r)?e.reloadQueued?(e.reloadQueued=!1,e.isLocal()?T.CACHED:(e.defer(),T.RESOLVE_VALUES)):T.CACHED:(e.defer(),e.isLocal()?T.EXPAND_LOCAL:T.EXPAND)},e.prototype.fetchTitle=function(e,t,r,n){void 0===r&&(r=!0);var o=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,new Y({columns:[o],deferRequest:r}),n).then(function(e){return e.getFields()[o]},this.errorHandler.reject)},e.prototype.createLocalEntries=function(e,t,r,n,o,i){var s=this;void 0===i&&(i=function(){return!0});var c=r.response,a={},u={},l=[],h=function(e,t,p){var f={itemType:e,itemId:t},d=c.items[e][p].links;for(var m in d)if(d.hasOwnProperty(m)){void 0===a[m]&&l.push({itemType:m,itemEntries:a[m]=[],columnSet:u[m]=s.columnSetFactory.construct(m,!0,r.responseColumns)});for(var y=0,v=d[m];y<v.length;y++){var g=v[y],C=n[m][g],I=s.itemEntryFactory.constructLocalLinked(m,C,c.fetchObject(m,g),f,u[m],n);i(I)&&(o.add(I),a[m].push(I),h(m,C,g))}}};return h(e,t,c.links[e][0]),l},e.prototype.expandLocalEntries=function(e,t,r,n,o){if(0===t.length)return this.promiseService.when(t);for(var i=this.columnExpansionFactory.construct(e,r,n),s=0,c=t;s<c.length;s++){var a=c[s],u=i.run(a.columns);null!==u&&a.expandLocal(u)}return this.resolveDerivedValues(t,i.aggregateRootColumns(),o)},e.prototype.resolveDerivedValues=function(e,t,r){for(var n=[],o=0,i=t;o<i.length;o++){var s=i[o];n.push(this.fetchDerivedValuesByColumn(e,s,r))}return this.promiseService.all(n).then(function(){return e},this.errorHandler.reject)},e.prototype.setDefaultValuesByColumn=function(e,t){var r=t.children;if(0!==r.length)for(var n=0,o=r;n<o.length;n++)for(var i=o[n],s=0,c=e;s<c.length;s++){c[s].derived[i.path]=this.apiFormatter.getDefaultValue(i.apiColumn.type)}},e.prototype.getItemIdByColumn=function(e,t){return 0===t.level?"link"===t.apiColumn.type&&null!==e.parent?e.parent.itemId:e.getFields()[t.path]:e.derived[t.path]},e.prototype.fetchDerivedValuesByColumn=function(e,t,r){var n=this,o=t.children;if(0===o.length)return this.promiseService.when();var i=o[0];if(1===o.length&&"id"===i.apiColumn.type){for(var s=0,c=e;s<c.length;s++){(h=c[s]).derived[i.path]=this.getItemIdByColumn(h,t)}return this.promiseService.when()}for(var a={},u=0,l=e;u<l.length;u++){var h=l[u],p=this.getItemIdByColumn(h,t);void 0===a[p]&&(a[p]=[]),a[p].push(h)}void 0!==a.null&&this.setDefaultValuesByColumn(a.null,t);var f=[];for(var p in a)"null"!==p&&f.push(+p);if(0===f.length)return this.promiseService.when();for(var d=[],m=0,y=o;m<y.length;m++){var v=y[m];d.push(v.id)}return this.fetchItems(t.itemType,f,new Y({columns:d}),r).then(function(t){for(var i=0,s=t;i<s.length;i++)for(var c=s[i],u=c.getFields(),l=0,h=a[c.itemId];l<h.length;l++)for(var p=h[l],f=0,d=o;f<d.length;f++){var m=d[f];p.derived[m.path]=u[m.id]}return n.resolveDerivedValues(e,o,r)},this.errorHandler.reject)},e.prototype.requestItem=function(e,t){return void 0===t&&(t=e.columns.request),this.requestItems(e.itemType,[e.itemId],t)},e.prototype.requestItems=function(e,t,r){var n;return this.apiRequestService.query(e,{id:t},((n={})[e]=r,n))},e}(),ke=function(){function e(e,t,r,n,o,i,s,c){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnExpansionFactory=n,this.columnSetFactory=o,this.itemEntryFactory=i,this.queryService=s,this.promiseService=c}return e.prototype.requestItem=function(e,t,r){var n,o=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},o)},e.prototype.requestItems=function(e,t,r){var n;void 0===t&&(t=e.query.object),void 0===r&&(r=e.options.columns);var o=e.itemType;return this.apiRequestService.requestSkeleton({requestType:"query",itemType:o,columns:(n={},n[o]=r,n),query:t,limit:e.options.limit})},e.prototype.requestLinkItems=function(e,t,r,n,o){var i,s=((i={})[r]=o,i);return null===n?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}}),s)},e.prototype.processExpansion=function(e,t,r,n){for(var o=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject()),i=0,s=n;i<s.length;i++){var c=s[i];c.isLocal()||this.handleCachedItem(c,t,o)}return o},e.prototype.processResponse=function(e,t,r,n,o){var i=this;void 0===o&&(o=this.columnExpansionFactory.construct(n.itemType,!!n.requestColumnsTrue||n.request,n.response));for(var s=this.itemHandler,c=n.itemType,a=n.root,u=[],l=[],h=0,p=t;h<p.length;h++){var f=p[h],d=s.entries.get(c,f);void 0===d?(d=this.itemEntryFactory.construct(f,e.fetchObject(c,f),e.fetchDerivedObject(c,f,a),n),s.entries.add(d),u.push(d)):d.isDeferred()?d.deferRequest?u.push(d.resolveDeferred(e.fetchObject(c,f),e.fetchDerivedObject(c,f,a),n)):l.push(d.deferred.promise):d.reloadQueued?(d.reloadQueued=!1,d.updateFields(e.fetchObject(c,f),e.fetchDerivedObject(c,f,a),!1),u.push(d)):u.push(this.handleCachedItem(d,e,o)),null!==r&&(d.parent=r)}return this.promiseService.all(l).then(function(t){for(var r=0,n=t;r<n.length;r++){var s=n[r];u.push(i.handleCachedItem(s,e,o))}return u},this.errorHandler.reject)},e.prototype.handleCachedItem=function(e,t,r){var n=r.run(e.columns);return null===n?e:e.expand(t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,n.difference.root),n)},e.prototype.processLinkResponse=function(e,t,r,n,o){for(var i=e.fetchColumnsObject(),s=this.columnSetFactory.construct(n,o.columns,i),c=this.columnExpansionFactory.construct(n,o.columns,i),a=e.items[t],u={},l=0,p=r;l<p.length;l++){var f=p[l];u[f]=h(a,[f,"links",n])?this.processResponse(e,a[f].links[n],{itemType:t,itemId:f},s,c):[]}return this.promiseService.all(u).then(function(e){return{items:e,columns:s,columnExpansion:c}},this.errorHandler.reject)},e}(),De=function(){function e(){this.separator=":"}return e.prototype.getSingleKey=function(e,t){return e+this.separator+t},e.prototype.getCssKey=function(){return Array.prototype.join.call(arguments,"_")},e.prototype.parseStateKey=function(e){return"new-"===(e=e.toString()).substring(0,"new-".length)?{type:"new",template:e.substring("new-".length)}:"dup-"===e.substring(0,"dup-".length)?{type:"duplicate",itemId:+e.substring("dup-".length)}:null},e.prototype.getDuplicateStateKey=function(e){return"dup-"+e},e.prototype.getNewStateKey=function(e){return"new-"+e},e.prototype.getLocalId=function(){return+("-1"+this.getRandomString())},e.prototype.getLocalDuplicateId=function(){return+("-2"+this.getRandomString())},e.prototype.getRandomString=function(){return(""+Math.random()).split(".")[1].substr(0,8)},e.prototype.isLocalId=function(e){return void 0!==e&&(this.isNewId(e)||this.isDuplicateId(e))},e.prototype.isNewId=function(e){return"new-"===e||"-1"===(""+e).substring(0,"-1".length)},e.prototype.isDuplicateId=function(e){return"dup-"===e||"-2"===(""+e).substring(0,"-2".length)},e}();!function(e){e.Always="always",e.OnClose="onClose",e.SkipOnClose="skipOnClose"}(B||(B={}));var Ae,He=function(){function e(e,t,r,n,o,i,s,c,a){void 0===a&&(a=""),this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=o,this.itemCacheFactory=i,this.collectionResourceFactory=s,this.promiseService=c,this.id=a,this.tabRequestParameters={},this.isSaving=!1,this.callbacks={onBeforeSave:{always:{},onClose:{},skipOnClose:{}},onSaveSuccess:{always:{},onClose:{},skipOnClose:{}}},this.changesInterval=null,this.hasChanges=!1,this.items=this.itemCacheFactory.construct(),this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct()}return e.prototype.createItemResource=function(e,t,r,n){var o=this;return void 0===r&&(r=!1),r&&(this.rootItem=e),t.onDeactivate=function(e){return o.onDeactivateItem(e)},this.itemResourceFactory.construct(e,t,n)},e.prototype.createItemResources=function(e,t){var r=this;t.onDeactivate=function(e){return r.onDeactivateItem(e)};for(var n=this.itemResourceFactory.getConstructor(t),o=[],i=0,s=e;i<s.length;i++){var c=s[i];o.push(n(c))}return o},e.prototype.createCollectionResource=function(e,t){return this.collectionResourceFactory.construct(e,t,this)},e.prototype.createCollectionResources=function(e,t){var r={};for(var n in e)r[n]=this.createCollectionResource(e[n],t);return r},e.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},e.prototype.clearItemEntry=function(e){this.items.clear(e),e.clearResources()},e.prototype.clearCollection=function(e){var t=e.entry;this.collections.clear(t),t.clearResources()},e.prototype.clearResources=function(e){void 0===e&&(e=!1),this.items.forEach(function(e){return e.clearResources()}),this.collections.forEach(function(t){return t.clearResources(e)}),this.deferredCollections.clear()},e.prototype.updateSingleItems=function(e){for(var t in e)for(var r in e[t]){var n=this.items.get(t,r);void 0!==n&&this.items.updateItemId(n,r)}},e.prototype.revertChanges=function(){var e=this;return this.items.forEach(function(e){return e.resetModified()}),this.collections.forEach(function(t){return e.resetCollection(t)}),this.hasChanges=!1,this.isLockable()?this.lockService.deleteLock(this.rootItem):this.promiseService.when()},e.prototype.resetCollection=function(e){if(e.items=e.initial.slice(),e.hasItemEditResources)for(var t=0,r=e.items;t<r.length;t++){r[t].resetModified()}},e.prototype.detectChanges=function(){var e=this;return!!this.hasChanges||(this.items.some(function(e){return e.hasChanges()})?this.hasChanges=!0:this.hasChanges=this.collections.some(function(t){return e.collectionHasChanges(t)}))},e.prototype.collectionHasChanges=function(e){return!(!e.hasEditResources||!e.hasAddedItems()&&!e.hasRemovedItems())||e.hasItemEditResources&&e.hasUpdatedItems()},e.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},e.prototype.save=function(e,t,r,n){var o=this;return void 0===e&&(e=!1),void 0===t&&(t={}),this.isSaving?this.errorHandler.reject():(this.isSaving=!0,this.detectChanges(),this.disableChangesWatcher(),(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(function(){return o.executeCallbackEvent(o.callbacks.onBeforeSave,function(e){return e(o)},e)},this.errorHandler.reject).then(function(){var e=m({},o.tabRequestParameters,t);return o.tabRequestParameters={},o.changesProcessorFactory.construct().execute(o.items.toArray(),o.collections.toArray(),e,r,n)},this.errorHandler.reject).then(function(t){return o.isLockable()&&o.lockService.clearLock(o.rootItem),o.hasChanges=!1,e||o.updateSingleItems(t),o.executeCallbackEvent(o.callbacks.onSaveSuccess,function(e){return e(o,t)},e).then(function(){return e||o.enableChangesWatcher(),o.isSaving=!1,t},o.errorHandler.reject)},this.errorHandler.reject).catch(function(e){return o.isSaving=!1,o.errorHandler.reject(e)}))},e.prototype.onBeforeSave=function(e,t,r){void 0===r&&(r=B.Always);var n=this.callbacks.onBeforeSave[r];return n[e]=t,function(){return delete n[e]}},e.prototype.onSaveSuccess=function(e,t,r){void 0===r&&(r=B.Always);var n=this.callbacks.onSaveSuccess[r];return n[e]=t,function(){return delete n[e]}},e.prototype.executeCallbackEvent=function(e,t,r){var n=this;return this.executeCallbacks(e[B.Always],t).then(function(){return n.executeCallbacks(e[r?B.OnClose:B.SkipOnClose],t)},this.errorHandler.reject)},e.prototype.executeCallbacks=function(e,t){var r={};for(var n in e)r[n]=t(e[n]);return this.promiseService.all(r)},e.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},e.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},e.prototype.onDeactivateItem=function(e){this.clearItemEntry(e)},e.prototype.onActivateItem=function(e){this.items.add(e)},e}(),Pe=function(){function e(e,t,r,n){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=n,this.lockItems={},this.promises={}}return e.prototype.getValue=function(e,t){var r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]},e.prototype.setValue=function(e,t,r){return p(r,[e.itemType,e.itemId],[{},t])},e.prototype.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){for(var t in this.lockItems)for(var r in this.lockItems[t]){var n=this.lockItems[t][r];if(!n.isForeign&&n.id==e)return!0}return!1},e.prototype.isLocked=function(e){var t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign},e.prototype.getMessage=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message},e.prototype.fetchCachedLock=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);var r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()},e.prototype.fetchLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},this.errorHandler.reject).then(function(e){return e.isForeign?t.errorHandler.reject(e.message):e.token},this.errorHandler.reject)},e.prototype.requestLock=function(e){var t=this,r=e.itemType,n=e.itemId,o=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:r,item:n}).then(function(o){return delete t.promises[r][n],t.setValue(e,o.fetchObject("Locktoken",o.links.Locktoken[0]),t.lockItems)},function(o){return delete t.promises[r][n],301===o.code?t.setValue(e,{isForeign:!0,message:o.message},t.lockItems):t.errorHandler.reject(o)});return this.setValue(e,o,this.promises)},e.prototype.deleteLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){if(void 0!==r){if(!r.isForeign)return t.apiRequestService.delete("Locktoken",r.id).then(function(){t.clearLock(e)},t.errorHandler.reject);t.clearLock(e)}},this.errorHandler.reject)},e.prototype.clearLock=function(e){var t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]},e}(),_e={},Ve=function(){function e(e,t,r){this.rootItemEntry=e,this.singleItemCache=t,this.collectionCache=r,this.parentMap={},this.destination={}}return e.prototype.process=function(){return this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{}),{itemType:this.rootItemEntry.itemType,itemId:this.rootItemEntry.itemId,items:this.destination}},e.prototype.createParentMap=function(e){var t={};return e.forEach(function(e){var r=e.itemType,n=e.parent;if(null!==n){var o=n.itemType,i=n.itemId;void 0===t[o]&&(t[o]={});var s=t[o];void 0===s[i]&&(s[i]={}),void 0===(s=s[i])[r]&&(s[r]=[]),s[r].push(e)}}),t},e.prototype.processItems=function(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(var n=0,o=t;n<o.length;n++){var i=o[n],s=i.itemId;void 0===this.destination[e][s]&&(r[e].push(s),this.destination[e][s]=this.processItem(i))}},e.prototype.processItem=function(e){var t=e.itemType,r=e.itemId,n=this.getItemsByParent(t,r),o=this.collectionCache.getCollectionsByParent(t,r),i=e.formatRequest(),c={};for(var a in n)this.processItems(a,n[a],c);for(var u=0,l=o;u<l.length;u++){var h=l[u];null===h.options.query&&this.processItems(h.itemType,h.items,c)}var p=s(i),f=s(c);return p&&f?{values:i,links:c}:p?{values:i}:f?{links:c}:_e},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),Be="maybe",Ne=function(){function e(e,t,r,n){void 0===n&&(n=null),this.apiFormatter=e,this.itemType=t,this.fields=r,this.parent=n}return e.prototype.compareValues=function(e,t){return n.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):n.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e},e.prototype.matchQuery=function(e){if(void 0!==e.search)return Be;if(void 0!==e.custom)return Be;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!s(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){if(e.reverse)return Be;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===Be?Be:e.not?!t:t},e.prototype.matchComplexQuery=function(e){var t,r,n=e.conditions;switch(e.operator){case"AND":t=!0,r=!1;break;case"OR":t=!1,r=!0;break;default:throw new Error("queryMatcher: Unsupported operator")}for(var o=0,i=n;o<i.length;o++){var s=i[o],c=this.matchQuery(s);if(c===r)return r;c===Be&&(t=Be)}return t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,o=t.value;if(!s(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),Be;switch("NOW"===o&&(o=n()),t.comparator){case"=":return this.compareValues(e,o);case"!=":return!this.compareValues(e,o);case"<":return e<o;case"<=":return e<=o;case">":return e>o;case">=":return e>=o;case"IN":return a(e,o);case"NOT IN":return!a(e,o);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}();!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(Ae||(Ae={}));var Ue=function(){function e(e,t){this.query=e,this.parameters=t}return e.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():n.isMoment(e)?n(e):n.isDuration(e)?n.duration(e):e},e.prototype.compareParsedQueries=function(e,t){return e[Ae.STR]===t[Ae.STR]?0:e[Ae.STR]>t[Ae.STR]?1:-1},e.prototype.parse=function(e){if(void 0===e&&(e=this.query),void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);var t=c(e);return null===t?[{},"{}"]:this.parseSimpleQuery(t,e[t])},e.prototype.parseSearchQuery=function(e){return[{search:(e=this.formatValue(e))[Ae.OBJ]},"[search"+Ae.SEP+e[Ae.STR]+"]"]},e.prototype.parseCustomQuery=function(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];var r=this.parseCustomParameters(t);return[{custom:e,parameters:r[Ae.OBJ]},"["+e+Ae.SEP+r[Ae.STR]+"]"]},e.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",o=0;o<t.length;o++){var i=t[o],s=this.formatValue(e[i]);r[i]=s[Ae.OBJ],o>0&&(n+=Ae.SEP),n+=s[Ae.STR]}return[r,n]},e.prototype.parseSimpleQuery=function(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[Ae.OBJ])?"IN":"="),[{key:e,value:t[Ae.OBJ],comparator:r},"["+r+Ae.SEP+e+Ae.SEP+t[Ae.STR]+"]"]},e.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var o=this.parse(t);return[{linkedTo:e,query:o[Ae.OBJ],reverse:r,not:n},"[linkedTo"+Ae.SEP+e+Ae.SEP+o[Ae.STR]+Ae.SEP+r+Ae.SEP+n+"]"]},e.prototype.parseComplexQuery=function(e,t){t=void 0===t?"AND":t.toUpperCase();var r=this.parseConditions(e);return[{conditions:r[Ae.OBJ],operator:t},"["+t+r[Ae.STR]+"]"]},e.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],o="",i=0,s=e;i<s.length;i++){var c=s[i];r.push(this.parse(c))}for(var a=0,u=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});a<u.length;a++){var l=u[a];n.push(l[Ae.OBJ]),o+=l[Ae.STR]}return[n,o]},e.prototype.formatValue=function(e){var t;if("string"==typeof e&&"&"===e.charAt(0)){var r=e.substring(1);if(void 0===(e=this.parameters[r]))throw new Error("queryParser: Undefined template parameter '"+r+"'");return[t=this.processValue(e),r+">"+e]}return[t=this.processValue(e),""+t]},e}(),Qe=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}},e.prototype.addParentCondition=function(e,t){var r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))},e.prototype.createNotIn=function(e){return{comparator:"NOT IN",key:"id",value:e}},e}(),Ye=function(){function e(e){this.columnUtil=e,this.columns={},this.columnSetIdMap={}}return e.prototype.expand=function(e){if(!this.columnSetIdMap[e.id]){var t=this.columns,r=e.itemType;void 0===t[r]&&(t[r]=[]),t[r]=this.columnUtil.mergeRequestColumns(t[r],e.request).merged,this.columnSetIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),Xe=function(){function e(e,t,r,n,o,i,s,c,a,u){this.promiseService=e,this.apiRequestService=t,this.itemHandler=r,this.itemEntryFactory=n,this.collectionHandler=o,this.columnSetFactory=i,this.columnExpansionFactory=s,this.requestColumnExpansionFactory=c,this.apiFormatter=a,this.errorHandler=u}return e.prototype.onMessageReceived=function(e){switch(e.body.eventType){case"update":return this.handleUpdate(e);case"create":return this.handleCreate(e);case"delete":return this.handleDelete(e);case"linkTo":return this.handleLinkMove()}},e.prototype.formatMessageValues=function(e,t){var r={};for(var n in t)r[n]=this.apiFormatter.formatResponseValue(t[n].type,e[n]);return r},e.prototype.createCollectionMap=function(e,t,r){var n={};for(var o in t){var i=t[o],s=null!==i.parent?i.parent:{};n[o]=this.collectionHandler.entries.getByFittingItem(e,this.formatMessageValues(i.values,r),s)}return n},e.prototype.groupByCollectionId=function(e,t){var r={};for(var n in t){var o=t[n];for(var i in o)for(var s=0,c=o[i];s<c.length;s++){var a=c[s],u=a.id;void 0===r[u]&&(r[u]={collection:a,fitting:[],notfitting:[],maybe:[]}),r[u][i].push("fitting"===i?this.itemHandler.entries.get(e,n):n)}}return r},e.prototype.getRequestColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();for(var n in t){for(var o=t[n].fitting,i=this.itemHandler.entries.get(e,n),s=0,c=o;s<c.length;s++){var a=c[s];r.expand(a.columns)}void 0!==i&&r.expand(i.columns)}return r.get()},e.prototype.deferEntry=function(e){var t=e.deferred;return void 0===t?e.defer():t.promise.then(this.deferEntry.bind(this),this.errorHandler.reject)},e.prototype.processMessage=function(e){var t=this,r=e.itemType,n=this.createCollectionMap(r,e.items[r],e.columns[r]),o=this.getRequestColumns(r,n),i=[],s=[];for(var c in n){var a=this.itemHandler.entries.get(r,c),u=+c;void 0===a?0!==n[u].fitting.length&&(this.itemHandler.entries.add(this.itemEntryFactory.constructDeferred(r,u,o[r],!1)),s.push(u)):(i.push(this.deferEntry(a)),s.push(u))}return 0===s.length?this.promiseService.when(this.groupByCollectionId(r,n)):this.promiseService.all(i).then(function(){return t.apiRequestService.query(r,{id:s},o)},this.errorHandler.reject).then(function(e){return t.handleResponse(r,s,o[r],e,n)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=e.items.FunctionChangesResolve,n=[],o=[];for(var i in r){var s=r[i].parent.itemId,c=this.itemHandler.entries.get("Functie",s);void 0!==c&&void 0!==c.columns.response.Functie.newchanges&&(n.push(this.deferEntry(c)),o.push(s))}return 0===o.length?this.promiseService.when():this.promiseService.all(n).then(function(){return t.apiRequestService.query("Functie",{id:o},{Functie:["newchanges"]})},this.errorHandler.reject).then(function(e){for(var r=0,n=e.links.Functie;r<n.length;r++){var o=n[r],i=t.itemHandler.entries.get("Functie",o),s=t.apiFormatter.copyFields(i.getFields(),{},i.columns.main),c=e.fetchValue("Functie",o,"newchanges");c!==s.newchanges&&i.setInitial({newchanges:c},!0).callOnChange(s).resolve()}},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleResponse=function(e,t,r,n,o){for(var i=n.fetchColumnsObject(),s=this.columnSetFactory.construct(e,r,i),c=this.columnExpansionFactory.construct(e,r,i),a=0,u=t;a<u.length;a++){var l=u[a],h=this.itemHandler.entries.get(e,l),p=void 0===h.initial,f=n.fetchObject(e,l);if(void 0!==f){var d=n.fetchDerivedObject(e,l,s.root);if(p)h.resolveDeferred(f,d,s);else{var m=c.run(h.columns),y=this.apiFormatter.copyFields(h.getFields(),{},h.columns.main);null!==m&&h.expand(f,d,m),h.updateFields(f,d,!1).callOnChange(y).resolve()}}else h.reject(),p&&this.itemHandler.entries.clear(h),delete o[l]}return this.groupByCollectionId(e,o)},e.prototype.isFunctionChangesResolveMessage=function(e){return"FunctionChangesResolve"===e.body.itemType},e.prototype.handleCreate=function(e){var t=this,r=e.body;return this.isFunctionChangesResolveMessage(e)?this.processFunctionChangesResolve(r):this.processMessage(r).then(function(e){return t.collectionHandler.addToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){var t=this;return this.processMessage(e.body).then(function(e){return t.collectionHandler.removeFromAndAddToCollections(e,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=e.body,r={},n=0,o=t.items;n<o.length;n++)for(var i=o[n],s=0,c=this.collectionHandler.entries.getByContainingItem(t.itemType,i);s<c.length;s++){var a=c[s];void 0===r[u=a.id]&&(r[u]={collection:a,items:[]}),r[u].items.push(i)}for(var u in r){var l=r[u];l.collection.removeItems(l.items,null,!0)}return this.promiseService.when()},e.prototype.handleLinkMove=function(){return this.promiseService.when()},e}(),Je=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new k(this.apiFormatter,e)},e}(),We=function(){function e(e){this.promiseService=e}return e.prototype.construct=function(e,t,r){return new H(this.promiseService,e,t,r)},e}(),Ke=function(){function e(e,t){this.collectionCacheFactory=e,this.keyService=t}return e.prototype.construct=function(e,t){return new P(this.collectionCacheFactory,this.keyService,e,t)},e}(),ze=function(){function e(e,t,r,n,o,i,s,c,a,u,l){this.apiFormatter=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.collectionEntryService=n,this.collectionHandler=o,this.columnExpansionFactory=i,this.createRequestFactory=s,this.errorHandler=c,this.itemHandler=a,this.promiseService=u,this.requestColumnExpansionFactory=l}return e.prototype.construct=function(){return new _(this.apiFormatter,this.apiRequestService,this.changesCompilationFactory,this.collectionEntryService,this.collectionHandler,this.columnExpansionFactory,this.createRequestFactory,this.errorHandler,this.itemHandler,this.promiseService,this.requestColumnExpansionFactory)},e}(),Ge=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new N(this.queryMatcherFactory)},e}(),Ze=function(){function e(e,t,r,n,o,i,s,c,a,u,l,h){this.collectionEntryService=e,this.columnHandler=t,this.columnExpansionFactory=r,this.columnSetFactory=n,this.errorHandler=o,this.itemEntryFactory=i,this.itemEntryService=s,this.itemHandler=c,this.itemRequestService=a,this.keyService=u,this.promiseService=l,this.queryService=h}return e.prototype.construct=function(e,t){return new ue(this,e,new oe(t))},e}(),$e=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e,t,r){return new ge(this.queryMatcherFactory,e,t,r)},e}(),et=function(){function e(e,t,r,n,o){this.errorHandler=e,this.itemResourceFactory=t,this.changesProcessorFactory=r,this.keyService=n,this.promiseService=o}return e.prototype.construct=function(e,t,r){var n=new ce(t);return n.editItems&&(e.hasItemEditResources=!0),n.editCollection?(e.hasEditResources=!0,new de(this,e,n,r)):new pe(this.itemResourceFactory,e,n,r)},e}(),tt=function(){function e(e){this.columnInfoFactory=e}return e.prototype.construct=function(e,t,r){return new Se(this.columnInfoFactory,e,t,r)},e}(),rt=function(){function e(){}return e.prototype.construct=function(e,t){return new Fe(e,t)},e}(),nt=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){return new be(this.columnHandler,this.columnUtil,this.columnInfoFactory,this,e,t)},e.prototype.construct=function(e,t,r,n,o){return this.constructStub(e,t).resolve(r,n,o)},e}(),ot=function(){function e(){}return e.prototype.construct=function(e){return new Oe(e)},e}(),it=function(){function e(e,t,r,n){this.collectionHandler=e,this.collectionMatcherFactory=t,this.keyService=r,this.requestColumnExpansionFactory=n}return e.prototype.construct=function(e,t,r,n){return new Me(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory,e,t,r,n)},e}(),st=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new Te(this.queryMatcherFactory)},e}(),ct=function(){function e(e,t,r,n,o,i){this.authInterface=e,this.apiFormatter=t,this.columnSetFactory=r,this.itemEntryService=n,this.keyService=o,this.promiseService=i}return e.prototype.constructStub=function(e,t,r){return new z(this,e,t,r)},e.prototype.constructLocalLinked=function(e,t,r,n,o,i){var s=this.constructStub(e,t,o);return s.parent=n,s.setLocalFields(r,i)},e.prototype.constructLocal=function(e,t,r,n,o,i,s){void 0===o&&(o=null),void 0===i&&(i=t.columns);var c=t.columns.itemType;void 0===s&&(s=this.itemEntryService.createLocalConversionMap(c,e,!0,t.response));var a=this.constructStub(c,e,i);return a.parent=o,a.setLocalFields(t.fields,s,t.columns).setModified(r).setDerived(n)},e.prototype.constructDeferred=function(e,t,r,n){var o=this.constructStub(e,t,this.columnSetFactory.constructStub(e,r));return o.defer(n),o},e.prototype.construct=function(e,t,r,n){return this.constructStub(n.itemType,e,n).setFields(t,r)},e}(),at=function(){function e(e,t,r,n,o){this.apiFormatter=e,this.lockService=t,this.changesProcessor=r,this.errorHandler=n,this.promiseService=o}return e.prototype.getConstructor=function(e){var t=this,r=new W(e);return function(e){return r.edit?new te(t,e,r):new $(e,r)}},e.prototype.construct=function(e,t,r){var n=new W(t);return t.edit?new te(this,e,n,r):new $(e,n,r)},e}(),ut=function(){function e(e,t,r,n,o,i,s,c){this.errorHandler=e,this.lockService=t,this.itemResourceFactory=r,this.collectionCacheFactory=n,this.changesProcessorFactory=o,this.itemCacheFactory=i,this.collectionResourceFactory=s,this.promiseService=c}return e.prototype.construct=function(e){return new He(this.errorHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.promiseService,e)},e}(),lt=function(){function e(){}return e.prototype.construct=function(e,t,r){return new Ve(e,t,r)},e}(),ht=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new Ne(this.apiFormatter,e,t,r)},e}(),pt=function(){function e(){}return e.prototype.construct=function(e,t){return new Ue(e,t)},e}(),ft=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new Ye(this.columnUtil)},e}(),dt=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r){return new me(this,e,t,r)},e}(),mt=function(){return function(e,t,r,n,o){this.noop=yt,this.version="1.5.4",this.apiFormatter=new x,this.keyService=new De,this.queryService=new Qe,this.columnUtil=new we,this.apiResponseProcessorFactory=new Je(this.apiFormatter),this.apiRequestService=new j(e,this.apiResponseProcessorFactory),this.itemEntryService=new xe(r,this.keyService),this.lockService=new Pe(this.apiRequestService,n,this.keyService,o),this.queryMatcherFactory=new ht(this.apiFormatter),this.itemCacheFactory=new st(this.queryMatcherFactory),this.batchStatusFactory=new We(o),this.columnCache=new Ie(this.columnUtil),this.columnHandler=new Re(this.apiRequestService,n,o,this.columnCache,this.columnUtil),this.columnInfoFactory=new rt,this.columnSubsetCacheFactory=new ot,this.columnExpansionFactory=new tt(this.columnInfoFactory),this.columnSetFactory=new nt(this.columnHandler,this.columnUtil,this.columnInfoFactory),this.templateFactory=new dt(this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new ct(r,this.apiFormatter,this.columnSetFactory,this.itemEntryService,this.keyService,o),this.itemHandler=new je(this.apiFormatter,this.apiRequestService,this.batchStatusFactory,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnSubsetCacheFactory,this.columnUtil,n,this.itemCacheFactory,this.itemEntryFactory,this.itemEntryService,this.keyService,o,this.templateFactory),this.itemRequestService=new ke(this.apiRequestService,n,this.itemHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryFactory,this.queryService,o),this.queryParserFactory=new pt,this.collectionEntryService=new ye(this.queryParserFactory,this.queryService),this.collectionResourceService=new Ce,this.collectionEntryFactory=new Ze(this.collectionEntryService,this.columnHandler,this.columnExpansionFactory,this.columnSetFactory,n,this.itemEntryFactory,this.itemEntryService,this.itemHandler,this.itemRequestService,this.keyService,o,this.queryService),this.collectionCacheFactory=new Ge(this.queryMatcherFactory),this.collectionMatcherFactory=new $e(this.queryMatcherFactory),this.collectionHandler=new ve(this.batchStatusFactory,this.collectionCacheFactory,this.collectionEntryFactory,this.collectionEntryService,this.collectionMatcherFactory,this.columnHandler,this.columnSetFactory,n,this.itemHandler,this.itemRequestService,this.keyService,o,this.queryParserFactory,this.queryService),this.requestColumnExpansionFactory=new ft(this.columnUtil),this.createRequestFactory=new it(this.collectionHandler,this.collectionMatcherFactory,this.keyService,this.requestColumnExpansionFactory),this.changesCompilationFactory=new Ke(this.collectionCacheFactory,this.keyService),this.changesProcessorFactory=new ze(this.apiFormatter,this.apiRequestService,this.changesCompilationFactory,this.collectionEntryService,this.collectionHandler,this.columnExpansionFactory,this.createRequestFactory,n,this.itemHandler,o,this.requestColumnExpansionFactory),this.itemResourceFactory=new at(this.apiFormatter,this.lockService,this.changesProcessorFactory.construct(),n,o),this.collectionResourceFactory=new et(n,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,o),this.localCacheFactory=new ut(n,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,o),this.moduleChangesCompilationFactory=new lt,this.itemAdministrator=new Le(this.apiRequestService,r,this.collectionHandler,this.collectionMatcherFactory,this.columnSetFactory,n,this.itemHandler,this.itemRequestService,this.keyService,this.localCacheFactory,t,this.moduleChangesCompilationFactory,o,this.queryService),this.socketMessageHandler=new Xe(o,this.apiRequestService,this.itemHandler,this.itemEntryFactory,this.collectionHandler,this.columnSetFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.apiFormatter,n)}}();function yt(){}function vt(e){return e}r.d(t,"RmCore",function(){return mt}),r.d(t,"noop",function(){return yt}),r.d(t,"identity",function(){return vt}),r.d(t,"ENTRY_STATUS",function(){return T}),r.d(t,"ALL_PERMISSIONS",function(){return"7"}),r.d(t,"COLUMN_SEPERATOR",function(){return A}),r.d(t,"RENDER_AS_SEPERATOR",function(){return":"}),r.d(t,"NEW_PREFIX",function(){return"-1"}),r.d(t,"DUPLICATE_PREFIX",function(){return"-2"}),r.d(t,"NEW_KEYWORD",function(){return"new-"}),r.d(t,"DUPLICATE_KEYWORD",function(){return"dup-"}),r.d(t,"ItemEntryOptionsInterface",function(){return Q}),r.d(t,"ItemEntryOptions",function(){return Y}),r.d(t,"ItemResourceOptionsInterface",function(){return J}),r.d(t,"ItemResourceOptions",function(){return W}),r.d(t,"ItemEntry",function(){return z}),r.d(t,"ItemResource",function(){return G}),r.d(t,"ViewResource",function(){return $}),r.d(t,"EditResource",function(){return te}),r.d(t,"CollectionEntryOptionsInterface",function(){return ne}),r.d(t,"CollectionEntryOptions",function(){return oe}),r.d(t,"CollectionResourceOptionsInterface",function(){return se}),r.d(t,"CollectionResourceOptions",function(){return ce}),r.d(t,"CollectionEntry",function(){return ue}),r.d(t,"CollectionResource",function(){return le}),r.d(t,"CollectionViewResource",function(){return pe}),r.d(t,"CollectionEditResource",function(){return de}),r.d(t,"Template",function(){return me}),r.d(t,"ApiFormatter",function(){return x}),r.d(t,"ApiRequestService",function(){return j}),r.d(t,"ApiResponseProcessor",function(){return k}),r.d(t,"BatchStatus",function(){return H}),r.d(t,"ChangesCompilation",function(){return P}),r.d(t,"ChangesProcessor",function(){return _}),r.d(t,"CollectionCache",function(){return N}),r.d(t,"CollectionEntryService",function(){return ye}),r.d(t,"CollectionHandler",function(){return ve}),r.d(t,"CollectionMatcher",function(){return ge}),r.d(t,"CollectionResourceService",function(){return Ce}),r.d(t,"ColumnCache",function(){return Ie}),r.d(t,"ColumnExpansion",function(){return Se}),r.d(t,"ColumnHandler",function(){return Re}),r.d(t,"ColumnInfo",function(){return Fe}),r.d(t,"ColumnSet",function(){return be}),r.d(t,"ColumnSubsetCache",function(){return Oe}),r.d(t,"ColumnUtil",function(){return we}),r.d(t,"CreateRequest",function(){return Me}),r.d(t,"ItemAdministrator",function(){return Le}),r.d(t,"ItemCache",function(){return Te}),r.d(t,"ItemEntryService",function(){return xe}),r.d(t,"ItemHandler",function(){return je}),r.d(t,"ItemRequestService",function(){return ke}),r.d(t,"KeyService",function(){return De}),r.d(t,"LocalCache",function(){return He}),r.d(t,"LockService",function(){return Pe}),r.d(t,"ModuleChangesCompilation",function(){return Ve}),r.d(t,"QueryMatcher",function(){return Ne}),r.d(t,"QueryParser",function(){return Ue}),r.d(t,"QueryService",function(){return Qe}),r.d(t,"RequestColumnExpansion",function(){return Ye}),r.d(t,"SocketMessageHandler",function(){return Xe}),r.d(t,"instantiateOptions",function(){return o}),r.d(t,"shallowMerge",function(){return i}),r.d(t,"hasProperties",function(){return s}),r.d(t,"getFirstProperty",function(){return c}),r.d(t,"inArray",function(){return a}),r.d(t,"filterArray",function(){return u}),r.d(t,"emptyArray",function(){return l}),r.d(t,"pathExists",function(){return h}),r.d(t,"createPath",function(){return p}),r.d(t,"getPath",function(){return f}),r.d(t,"extend",function(){return m}),r.d(t,"merge",function(){return y}),r.d(t,"isObject",function(){return v}),r.d(t,"isBlankObject",function(){return g}),r.d(t,"isString",function(){return C}),r.d(t,"isNumber",function(){return I}),r.d(t,"isDate",function(){return S}),r.d(t,"isArray",function(){return R}),r.d(t,"isFunction",function(){return F}),r.d(t,"isRegExp",function(){return E}),r.d(t,"isBoolean",function(){return q}),r.d(t,"isElement",function(){return b}),r.d(t,"isWindow",function(){return O}),r.d(t,"isDefined",function(){return w}),r.d(t,"equals",function(){return M}),r.d(t,"copy",function(){return L}),r.d(t,"ApiResponseProcessorFactory",function(){return Je}),r.d(t,"BatchStatusFactory",function(){return We}),r.d(t,"ChangesCompilationFactory",function(){return Ke}),r.d(t,"ChangesProcessorFactory",function(){return ze}),r.d(t,"CollectionCacheFactory",function(){return Ge}),r.d(t,"CollectionEntryFactory",function(){return Ze}),r.d(t,"CollectionMatcherFactory",function(){return $e}),r.d(t,"CollectionResourceFactory",function(){return et}),r.d(t,"ColumnExpansionFactory",function(){return tt}),r.d(t,"ColumnInfoFactory",function(){return rt}),r.d(t,"ColumnSetFactory",function(){return nt}),r.d(t,"ColumnSubsetCacheFactory",function(){return ot}),r.d(t,"CreateRequestFactory",function(){return it}),r.d(t,"ItemCacheFactory",function(){return st}),r.d(t,"ItemEntryFactory",function(){return ct}),r.d(t,"ItemResourceFactory",function(){return at}),r.d(t,"LocalCacheFactory",function(){return ut}),r.d(t,"ModuleChangesCompilationFactory",function(){return lt}),r.d(t,"QueryMatcherFactory",function(){return ht}),r.d(t,"QueryParserFactory",function(){return pt}),r.d(t,"RequestColumnExpansionFactory",function(){return ft}),r.d(t,"TemplateFactory",function(){return dt}),r.d(t,"LocalCacheCallbackCondition",function(){return B})}])});
|