@rentman/rm-core 2.0.11 → 2.0.12

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.
Files changed (107) hide show
  1. package/changelog.md +600 -595
  2. package/dist/rm-core.js +9348 -9342
  3. package/dist/rm-core.min.js +1 -1
  4. package/dist/src/classes/ApiFormatter.d.ts +55 -55
  5. package/dist/src/classes/ApiRequestService.d.ts +20 -20
  6. package/dist/src/classes/ApiResponseProcessor.d.ts +29 -29
  7. package/dist/src/classes/ChangesCompilation.d.ts +34 -34
  8. package/dist/src/classes/ChangesDelta.d.ts +42 -42
  9. package/dist/src/classes/ChangesDeltaBase.d.ts +33 -33
  10. package/dist/src/classes/ChangesProcessor.d.ts +47 -47
  11. package/dist/src/classes/CollectionCache.d.ts +37 -37
  12. package/dist/src/classes/CollectionEntryService.d.ts +25 -25
  13. package/dist/src/classes/CollectionMatcher.d.ts +9 -9
  14. package/dist/src/classes/CollectionMatcherBase.d.ts +26 -26
  15. package/dist/src/classes/CollectionResourceService.d.ts +6 -6
  16. package/dist/src/classes/ColumnCache.d.ts +21 -21
  17. package/dist/src/classes/ColumnExpansion.d.ts +22 -22
  18. package/dist/src/classes/ColumnHandler.d.ts +21 -21
  19. package/dist/src/classes/ColumnInfo.d.ts +14 -14
  20. package/dist/src/classes/ColumnSet.d.ts +39 -39
  21. package/dist/src/classes/ColumnSubsetCache.d.ts +8 -8
  22. package/dist/src/classes/ColumnUtil.d.ts +99 -99
  23. package/dist/src/classes/CreateRequest.d.ts +19 -19
  24. package/dist/src/classes/InternalChangesDelta.d.ts +38 -38
  25. package/dist/src/classes/ItemCache.d.ts +29 -29
  26. package/dist/src/classes/ItemEntryService.d.ts +41 -41
  27. package/dist/src/classes/KeyService.d.ts +16 -16
  28. package/dist/src/classes/LockService.d.ts +32 -32
  29. package/dist/src/classes/ModuleChangesCompilation.d.ts +18 -18
  30. package/dist/src/classes/QueryColumnExtractor.d.ts +20 -20
  31. package/dist/src/classes/QueryMatcher.d.ts +14 -14
  32. package/dist/src/classes/QueryParser.d.ts +25 -25
  33. package/dist/src/classes/QueryParserBase.d.ts +29 -29
  34. package/dist/src/classes/QueryService.d.ts +14 -14
  35. package/dist/src/classes/RequestBuffer.d.ts +25 -25
  36. package/dist/src/classes/RequestBufferManager.d.ts +31 -31
  37. package/dist/src/classes/RequestColumnExpansion.d.ts +15 -15
  38. package/dist/src/classes/SocketMessageHandler.d.ts +31 -31
  39. package/dist/src/classes/TemplateCache.d.ts +63 -63
  40. package/dist/src/classes/Util.d.ts +28 -28
  41. package/dist/src/classes/cache/AbstractCache.d.ts +140 -140
  42. package/dist/src/classes/cache/CollectionHandlerBase.d.ts +64 -64
  43. package/dist/src/classes/cache/CollectionMatcherCacheProcessor.d.ts +26 -26
  44. package/dist/src/classes/cache/ItemHandlerBase.d.ts +95 -95
  45. package/dist/src/classes/cache/server/ServerCache.d.ts +98 -98
  46. package/dist/src/classes/cache/server/ServerCollectionHandler.d.ts +43 -43
  47. package/dist/src/classes/cache/server/ServerItemHandler.d.ts +50 -50
  48. package/dist/src/classes/cache/transaction/TransactionCache.d.ts +412 -412
  49. package/dist/src/classes/cache/transaction/TransactionCollectionHandler.d.ts +72 -72
  50. package/dist/src/classes/cache/transaction/TransactionEventHandler.d.ts +19 -19
  51. package/dist/src/classes/cache/transaction/TransactionItemHandler.d.ts +114 -114
  52. package/dist/src/classes/index.d.ts +41 -41
  53. package/dist/src/constants.d.ts +7 -7
  54. package/dist/src/core.d.ts +49 -49
  55. package/dist/src/factories/ApiResponseProcessorFactory.d.ts +6 -6
  56. package/dist/src/factories/ChangesCompilationFactory.d.ts +6 -6
  57. package/dist/src/factories/ChangesDeltaFactory.d.ts +9 -9
  58. package/dist/src/factories/ChangesProcessorFactory.d.ts +22 -22
  59. package/dist/src/factories/CollectionCacheFactory.d.ts +8 -8
  60. package/dist/src/factories/CollectionEntryFactory.d.ts +11 -11
  61. package/dist/src/factories/CollectionMatcherFactory.d.ts +9 -9
  62. package/dist/src/factories/CollectionResourceFactory.d.ts +34 -34
  63. package/dist/src/factories/ColumnExpansionFactory.d.ts +8 -8
  64. package/dist/src/factories/ColumnInfoFactory.d.ts +7 -7
  65. package/dist/src/factories/ColumnSetFactory.d.ts +19 -19
  66. package/dist/src/factories/ColumnSubsetCacheFactory.d.ts +6 -6
  67. package/dist/src/factories/CreateRequestFactory.d.ts +11 -11
  68. package/dist/src/factories/ItemCacheFactory.d.ts +8 -8
  69. package/dist/src/factories/ItemEntryFactory.d.ts +17 -17
  70. package/dist/src/factories/ItemResourceFactory.d.ts +32 -32
  71. package/dist/src/factories/ModuleChangesCompilationFactory.d.ts +5 -5
  72. package/dist/src/factories/QueryMatcherFactory.d.ts +7 -7
  73. package/dist/src/factories/QueryParserFactory.d.ts +6 -6
  74. package/dist/src/factories/RequestColumnExpansionFactory.d.ts +6 -6
  75. package/dist/src/factories/TemplateFactory.d.ts +10 -10
  76. package/dist/src/factories/TransactionCacheFactory.d.ts +55 -55
  77. package/dist/src/factories/index.d.ts +22 -22
  78. package/dist/src/index.d.ts +7 -7
  79. package/dist/src/interfaces/ApiRequestServiceInterface.d.ts +11 -11
  80. package/dist/src/interfaces/AuthInterface.d.ts +9 -9
  81. package/dist/src/interfaces/ErrorHandlerInterface.d.ts +5 -5
  82. package/dist/src/interfaces/ExceptionHandlerInterface.d.ts +3 -3
  83. package/dist/src/interfaces/LinkTreeServiceInterface.d.ts +4 -4
  84. package/dist/src/interfaces/PromiseLibraryInterface.d.ts +25 -25
  85. package/dist/src/interfaces/SocketMessageInterface.d.ts +3 -3
  86. package/dist/src/interfaces/index.d.ts +7 -7
  87. package/dist/src/models/CollectionEditResource.d.ts +17 -17
  88. package/dist/src/models/CollectionEntry.d.ts +27 -27
  89. package/dist/src/models/CollectionEntryOptions.d.ts +13 -13
  90. package/dist/src/models/CollectionResource.d.ts +52 -52
  91. package/dist/src/models/CollectionResourceOptions.d.ts +27 -27
  92. package/dist/src/models/CollectionViewResource.d.ts +7 -7
  93. package/dist/src/models/EditResource.d.ts +16 -16
  94. package/dist/src/models/ItemEntry.d.ts +19 -19
  95. package/dist/src/models/ItemEntryOptions.d.ts +9 -9
  96. package/dist/src/models/ItemResource.d.ts +87 -87
  97. package/dist/src/models/ItemResourceOptions.d.ts +9 -9
  98. package/dist/src/models/LocalViewResource.d.ts +7 -7
  99. package/dist/src/models/RemoteViewResource.d.ts +7 -7
  100. package/dist/src/models/Template.d.ts +11 -11
  101. package/dist/src/models/ViewResource.d.ts +8 -8
  102. package/dist/src/models/index.d.ts +15 -15
  103. package/dist/src/types/ItemTypesCollection.d.ts +262 -262
  104. package/dist/src/types/PromiseInterface.d.ts +2 -2
  105. package/dist/src/types/index.d.ts +2 -2
  106. package/package.json +36 -36
  107. package/readme.md +15 -15
@@ -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 a(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function c(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,a=r;s<a.length;s++){var c=a[s];e.push(c)}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 d(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 f(e,t,r){for(var n=0,o=t.length;n<o;++n){var i=t[n];if(v(i)||S(i))for(var s=Object.keys(i),a=0,c=s.length;a<c;a++){var u=s[a],l=i[u];r&&v(l)?F(l)?e[u]=new Date(l.valueOf()):R(l)?e[u]=new RegExp(l):l.nodeName?e[u]=l.cloneNode(!0):T(l)?e[u]=l.clone():(v(e[u])||(e[u]=E(l)?[]:{}),f(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 f(e,t,!1)}function y(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return f(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 F(e){return"[object Date]"===toString.call(e)}var E=Array.isArray;function S(e){return"function"==typeof e}function R(e){return"[object RegExp]"===toString.call(e)}function q(e){return"boolean"==typeof e}function T(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function w(e){return e&&e.window===e}function b(e){return void 0!==e}function H(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,a=typeof e;if(a===typeof t&&"object"===a){if(!E(e)){if(F(e))return!!F(t)&&(i=e.getTime(),s=t.getTime(),i===s||i!=i&&s!=s);if(R(e))return!!R(t)&&e.toString()===t.toString();if(w(e)||w(t)||E(t)||F(t)||R(t))return!1;for(n in o=Object.create(null),e)if(!S(e[n])){if(!H(e[n],t[n]))return!1;o[n]=!0}for(n in t)if(!(n in o)&&b(t[n])&&!S(t[n]))return!1;return!0}if(!E(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!H(e[n],t[n]))return!1;return!0}}return!1}function M(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(E(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 a(e,r);function s(e,t,r){if(--r<0)return"...";if(E(e))for(var n=0,o=e.length;n<o;n++)t.push(a(e[n],r));else if(g(e))for(var i in e)t[i]=a(e[i],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var i in e)e.hasOwnProperty(i)&&(t[i]=a(e[i],r));else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=a(e[i],r));return t}function a(e,t){if(void 0===t&&(t=5),!v(e))return e;var r=n.indexOf(e);if(-1!==r)return o[r];if(w(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var i=!1,c=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(a(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(S(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===c&&(c=E(e)?[]:Object.create(Object.getPrototypeOf(e)),i=!0),n.push(e),o.push(c),i?s(e,c,t):c}}var x,k,D=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.isExpensiveFormat=function(e){switch(e){case"date":case"datetime":case"duration":return!0;default:return!1}},e.prototype.mergeCopyFields=function(e,t,r,n){for(var o=0,i=n;o<i.length;o++){var s=i[o],a=s.path;void 0===r[a]||"id"!==a&&void 0!==t[a]&&!this.compareFields(s.apiColumn.type,t[a],e[a])||(t[a]=this.clone(s.apiColumn.type,r[a]))}return t},e.prototype.formatRequest=function(e,t,r){for(var n={},o=0,i=r;o<i.length;o++){var s=i[o],a=s.id,c=s.apiColumn,u=c.type;c.readOnly||(this.compareFields(u,e[a],t[a])||(n[a]=this.formatRequestValue(u,t[a])))}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,a=i.apiColumn;a.readOnly||(r[s]=this.formatRequestValue(a.type,e[s]))}return r},e.prototype.hasChanges=function(e,t,r,n){void 0===n&&(n=!1);for(var o=0,i=r;o<i.length;o++){var s=i[o],a=s.id,c=s.apiColumn;if(n||!c.readOnly){if(this.isExpensiveFormat(s.apiColumn.type)){var u=Object.getOwnPropertyDescriptor(t,a);if(void 0!==u&&void 0===u.value&&void 0!==u.get)continue}if(!this.compareFields(c.type,e[a],t[a]))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],a=s.id,c=s.apiColumn;c.readOnly||(this.compareFields(c.type,e[a],t[a])||n.push({oldValue:e[a],newValue:t[a],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;e.hasOwnProperty(s)&&(this.isExpensiveFormat(i.apiColumn.type)||void 0!==e[s])&&(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],a=s.path;r[a]=void 0!==e[a]?e[a]:this.clone(s.apiColumn.type,t[a])}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":case"order":return t===r;default:return H(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":case"order":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 M(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}(),O=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}(),P=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.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t]){var n=this.columnMap[e][r],o=this.columnIndexMap[e][r];return this.apiFormatter.formatResponseValue(n.type,this.items[e][t].data[o])}},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.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){var n=this;if((void 0===r&&(r=!1),void 0!==this.items[e])&&void 0!==this.items[e][t]){for(var o=this.items[e][t].data,i={},s=function(t){var r=a.columns[e][t];a.apiFormatter.isExpensiveFormat(r.type)?Object.defineProperty(i,r.id,{enumerable:!0,configurable:!0,set:function(e){delete i[r.id],i[r.id]=e},get:function(){return delete i[r.id],i[r.id]=n.apiFormatter.formatResponseValue(r.type,o[t])}}):i[r.id]=a.apiFormatter.formatResponseValue(r.type,o[t])},a=this,c=0;c<o.length;c++)s(c);if(r){var u=this.items[e][t].links;for(var l in i.__links={},u)i.__links[l]=this.fetchObjectArray(l,r,u[l])}return i}},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.fetchColumnsObject=function(){return this.columnMap},e}(),_=function(){function e(e){this.transaction=e,this.compilation={create:{},delete:{},update:{},move:{}},this.processDelta()}return e.prototype.processDelta=function(){var e=this.transaction.getDelta();for(var t in e.deleted)for(var r=0,n=e.deleted[t];r<n.length;r++){var o=n[r];o.isLocal()||this.addDeleteEntry(o)}for(var i in e.created){var s=e.created[i];this.addCreateEntry(s)}for(var i in e.updated){s=e.updated[i];this.addUpdateEntry(s.entry)}for(var i in e.moved){s=e.moved[i];this.addMoveEntry(s.entry,s.to)}},e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e,t){p(this.compilation.move,[t.itemType,t.itemId],[{},[]]).push(e)},e.prototype.addDeleteEntry=function(e){p(this.compilation.delete,[e.itemType],[[]]).push(e)},e.prototype.addUpdateEntry=function(e){p(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=this.transaction.getParent(e.entry);null===t&&(t=this.getDefaultParent()),p(this.compilation.create,[t.itemType,t.itemId,e.entry.itemType,e.entry.itemId],[{},{},{},e])},e}(),j=function(){function e(e,t,r,n,o,i,s,a,c,u,l,h,p){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=o,this.errorHandler=i,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u,this.transaction=l,this.breakUpByParent=h,this.onAfterCreateCallback=p,this.itemIdConversionMap={},this.serverCache=this.transaction.getServerCache()}return e.prototype.execute=function(){var e=this,t=this.changesCompilationFactory.construct(this.transaction),r=t.compilation;return this.executeCreateRequests(t).then(function(){return e.executeMoveRequests(r.move)},this.errorHandler.reject).then(function(){return e.executeUpdateRequests(r.update)},this.errorHandler.reject).then(function(){return e.executeDeleteRequests(r.delete)},this.errorHandler.reject).then(function(){return e.itemIdConversionMap},this.errorHandler.reject)},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var o=n[r],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&&(r=this.itemIdConversionMap),void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e){for(var t=this,r=[],n=0,o=this.createRequestFactory.construct(e.compilation.create,this.transaction,this.breakUpByParent).run();n<o.length;n++){var i=o[n];r.push(this.executeCreateRequest(i).then(function(e){return void 0!==t.onAfterCreateCallback&&t.onAfterCreateCallback(t.itemIdConversionMap),e},this.errorHandler.reject))}return this.promiseService.all(r)},e.prototype.executeCreateRequest=function(e){var t=this;return this.apiRequestService.requestSkeleton(e.request).then(function(r){var n=t.changesDeltaFactory.construct(),o=r.map,i=r.fetchColumnsObject(),a=e.items;for(var c in a){var u=t.columnExpansionFactory.construct(c,e.request.columns[c],i);for(var l in a[c]){var h=a[c][l],p=t.getMapValue(c,parseInt(l,10),o);if(void 0!==p){var d=t.transaction.itemHandler.entries.get(c,l);d.itemId=p,t.serverCache.itemHandler.copyTransactionItemEntryChanges(t.transaction.itemHandler.itemChanges[d.id],d),t.serverCache.itemHandler.entries.add(d),t.transaction.itemHandler.entries.clearByItemId(c,Number(l)),t.serverCache.itemHandler.processApiResponse(n,r,h.itemType,Number(p),h.columns,u)}else console.warn("Create failed!",h)}}for(var c in o)for(var l in void 0===t.itemIdConversionMap[c]&&(t.itemIdConversionMap[c]={}),o[c])t.itemIdConversionMap[c][l]=o[c][l];for(var f=0,m=t.transaction.collectionHandler.entries.toArray();f<m.length;f++){var y=m[f],v=y.parent;if(null!==v){var g=t.getMapValue(v.itemType,v.itemId);void 0!==g&&(v.itemId=g,y.query=t.collectionEntryService.createQuery(y.options))}var C=y.getUpdatedItemColumns(t.itemIdConversionMap);s(C)&&(void 0!==C.id&&t.transaction.collectionHandler.onItemEntriesCreated(y,t.itemIdConversionMap[y.itemType]))}t.serverCache.applyChangesDelta(n)},this.errorHandler.reject)},e.prototype.executeUpdateRequests=function(e){var t=[];for(var r in e)t.push(this.executeUpdateRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeUpdateRequest=function(e,t){var r=this,n={},o=this.requestColumnExpansionFactory.construct(),i=this.transaction.collectionHandler.getCollectionMatcher();for(var s in n[e]={},t){var a=t[s],c=n[e][s]={},u=d(this.transaction.tabRequestParameters,[e,s]);c.values=this.transaction.itemHandler.formatRequest(a),void 0!==u&&(c.parameters=u),o.expand(a.columns),i.expand(a,this.transaction.itemHandler.itemChanges[a.id].changes)}for(var l=0,h=i.getCollectionsWithFittingItems();l<h.length;l++){var p=h[l];o.expand(p.columns)}var f=o.get();return this.apiRequestService.updateItems(e,n,f).then(function(e){return r.serverCache.processResponse(e,!0,!1)},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){var r=this;return this.apiRequestService.delete(e,t.map(function(e){return e.itemId})).then(function(e){for(var n=r.changesDeltaFactory.constructInternalDelta(),o=e.items,i=[],s=0,a=t;s<a.length;s++){var u=a[s];c(u.itemId,o)?i.push(u):console.warn("Delete failed!",u)}n.setItemsDeleted(i),r.serverCache.applyChangesFromParent(n,!0)},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e){var t=this,r=[],n=function(n,o){var i=e[n][o],s=t.getMapValue(n,o);r.push(t.apiRequestService.moveItems(n,void 0!==s?s:o,t.buildMoveRequest(i)).then(function(){for(var e=t.changesDeltaFactory.constructInternalDelta(),r=0,a=i;r<a.length;r++){var c=a[r];e.setItemUpdated(c,t.itemEntryService.getLinkFieldsByParent({itemType:n,itemId:void 0!==s?s:o},c.itemType))}t.serverCache.applyChangesFromParent(e,!0)},t.errorHandler.reject))};for(var o in e)for(var i in e[o])n(o,+i);return this.promiseService.all(r)},e}(),L=function(){return function(e){this.columns=!0,this.parent=null,this.templateOptions={},this.templateColumns={},o(this,e)}}(),A=function(){return function(e){this.edit=!1,this.remote=!1,this.onChange=Nt,o(this,e)}}(),B=0,Q=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++B,this.reloadQueued=!1}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},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.toJSON=function(){return{id:this.id,columns:this.columns}},e}(),U=function(){function e(e,t,r,n,o){this.factory=e,this.entry=t,this.options=r,this._isNew=n,this.transaction=o,this.columns=t.columns.response[t.columns.itemType],this.initial=this.transaction.itemHandler.itemChanges[t.id].initial,this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.getParent=function(e){return this.transaction.getParent(this.entry,e,this.fields)},e.prototype.callOnChange=function(e){var t=this,r=this.transaction.itemHandler.itemResources[this.entry.id];if(void 0!==r)for(var n=0,o=r;n<o.length;n++){var i=o[n];try{i.options.onChange(i,e,function(r){return t.compareItemField(r,e)},!1)}catch(e){this.factory.exceptionHandler(e)}}},e.prototype.compareItemField=function(e,t){var r=this.columns[e];if(void 0===r)throw new Error("Missing column in ItemResource.compareItemField");return this.factory.apiFormatter.compareFields(r.type,this.fields[e],t[e])},e.prototype.hasChanges=function(){return this.transaction.itemHandler.detectEntryChanges(this.entry.id)},e.prototype.setTransactionParameters=function(e){p(this.transaction.tabRequestParameters,[this.entry.itemType,this.entry.itemId],[{},e])},e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.clearResource=function(){this.transaction.clearItemResource(this)},e.prototype.toJSON=function(){var e=[];for(var t in this.columns)e.push(t);return{columns:e,fields:this.fields,entry:this.entry}},e.prototype.getDerivedValue=function(e){return this.transaction.itemHandler.getDerivedValue(this.entry,e)},e.prototype.getDerivedValues=function(e){return this.transaction.itemHandler.getDerivedValues(this.entry,e)},e}(),V=(x=function(e,t){return(x=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}x(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),N=function(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.fields=i.itemHandler.itemChanges[r.id].changes,s}return V(t,e),t}(U),W=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)}}(),Y=function(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.localCopies=[],s.fields=i.itemHandler.itemChanges[r.id].changes,s}return W(t,e),t.prototype.isNew=function(){return this._isNew},t.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(this.fields,e,t.columns.main),e},t.prototype.setFields=function(e){var t=this,r=this.columns;for(var n in e){void 0===r[n]&&console.warn("setFields: no column found for",n)}var o=this.transaction.createChangesDelta();return o.setItemUpdated(this.entry,e),this.transaction.applyChangesDelta(o).then(function(){return t},this.factory.errorHandler.reject)},t}(U),J=function(){return function(e){this.columns=[],this.query=null,this.queryParams={},this.queryColumns=[],this.parent=null,this.deferRequest=!1,this.limit=null,this.entryKey=null,o(this,e)}}(),K=function(){return function(e){this.editItems=!1,this.remoteItems=!1,this.editCollection=!1,this.enableSave=!0,this.callOnAddWithInitialItems=!1,this.onItemsCreated=Nt,this.onChange=Nt,this.onAdd=Nt,this.onRemove=Nt,this.onAddInitial=Nt,this.onRemoveInitial=Nt,this.resourceKey=null,this.custom=null,o(this,e)}}(),z=0,X=function(){function e(e,t,r,n,o){this.collectionEntryService=e,this.columnSetFactory=t,this.keyService=r,this.itemType=n,this.options=o,this.id=z++,this.parent=null,this.reloadQueued=!1,this.parent=o.parent,this.query=this.collectionEntryService.createQuery(o),this.columns=this.columnSetFactory.constructStub(n,o.columns)}return e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.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.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.collectionEntryService.createQuery(t))},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.options.columns=this.columns.request)},e.prototype.expandRequestColumns=function(e){this.columns.expandRequestColumns(e),this.options.columns=this.columns.request},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}(),G=function(){function e(e,t,r,n){var o=this;this.factory=e,this.entry=t,this.options=r,this.transaction=n,this.itemIdMap={},this.items=[],this.itemIdMap={},this.columns=t.columns.response,this.onChange=function(e,t,r,n){e.compareItemField("id",t)||(delete o.itemIdMap[t.id],o.itemIdMap[e.entry.itemId]=e),o.options.onChange(e,t,function(r){return e.compareItemField(r,t)},n)},this.addItemResources(this.transaction.collectionHandler.collectionChanges[this.entry.id],!0),this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.getIdArray=function(){return this.items.map(function(e){return e.entry.itemId})},e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.addItemResources=function(e,t){if(void 0===t&&(t=!1),0===e.length)return[];var r=this.items.map(function(e){return e.entry});e=e.filter(function(e){return-1===r.indexOf(e)});for(var n=this.transaction.createItemResources(e,{remote:this.options.remoteItems,edit:this.options.editItems,onChange:this.onChange}),o=0,i=n;o<i.length;o++){var s=i[o],a=s.entry.itemId;if(void 0!==this.itemIdMap[a])throw new Error("Added a resource of an entry that was already in the collection !");this.items.push(s),this.itemIdMap[a]=s}return t&&!this.options.callOnAddWithInitialItems||this.callOnAdd(n,t),n},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 n.clearResource(),r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e,t){void 0===t&&(t=!1);try{this.options.onAdd(e,this,t)}catch(e){this.factory.exceptionHandler(e)}},e.prototype.callOnRemove=function(e){try{this.options.onRemove(e,this)}catch(e){this.factory.exceptionHandler(e)}},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){if(void 0===this.entry.columns.response[this.entry.itemType][e])throw new Error("Trying to group on a column not requested by this collection! (column '"+e+"')");for(var n=0,o=t;n<o.length;n++){void 0===r[c=(a=o[n]).fields[e]]&&(r[c]=[]),r[c].push(a)}}if("function"==typeof e)for(var i=0,s=t;i<s.length;i++){var a,c;null!==(c=e(a=s[i]))&&(void 0===r[c]&&(r[c]=[]),r[c].push(a))}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){return this.transaction.collectionHandler.extendCollectionEntry(this.entry,e)},e.prototype.clearResource=function(e){if(void 0===e&&(e=!0),e)for(var t=0,r=this.items;t<r.length;t++){r[t].clearResource()}this.transaction.clearCollectionResource(this)},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,o){return e.call(this,t,r,n,o)||this}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){return e.call(this,t,r,n,o)||this}return ee(t,e),t.prototype.moveItems=function(e,t){if(this.options.enableSave)throw new Error("collectionResourceService: Cannot move items: saving enabled");return this.transaction.collectionHandler.moveItems(this.entry,t.entry,e)},t.prototype.removeItems=function(e){for(var t=this.factory.changesDeltaFactory.construct(),r=[],n=0,o=this.items;n<o.length;n++){var i=o[n].entry;-1!==e.indexOf(i.itemId)&&r.push(i)}t.setItemsDeleted(r),this.transaction.applyChangesDelta(t)},t.prototype.removeItem=function(e){return this.removeItems([e])},t.prototype.addItems=function(e){return this.transaction.itemHandler.createItems(this.entry.itemType,e,this.entry.parent)},t.prototype.addItem=function(e){return this.addItems([e])},t}(G),re=function(){return function(e,t,r,n,o){this.itemType=t,this.response=r,this.fields=r.fetchObject(t,r.links[t][0]);var i=r.fetchColumnsObject();this.responseColumns=e.columnUtil.mergeResponseColumns(i,o).merged,this.columns=e.columnSetFactory.constructFromResponse(t,i),this.columns=this.columns.expand(n[t],!1,o).merged}}(),ne=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)}}(),oe=function(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.fields=s.transaction.itemHandler.itemChanges[r.id].initial,s}return ne(t,e),t}(N),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(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.fields=i.itemHandler.itemChanges[r.id].changes,s}return ie(t,e),t}(N);!function(e){e.ITEMTABLE="itemtable",e.DIRECT="direct"}(k||(k={}));var ae,ce=function(){function e(e,t,r,n,o,i,s,a){this.columnUtil=e,this.apiFormatter=t,this.itemEntryFactory=r,this.promiseService=n,this.errorHandler=o,this.requestColumnExpansionFactory=i,this.transaction=a,this.entries=s.construct(this.transaction)}return e.prototype.getDerivedValues=function(e,t){for(var r=e,n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),o=0,i=t;o<i.length;o++){var s=i[o],a=r.columns.response[r.itemType][s];if(void 0===a)throw new Error("Column '"+s+"' not found on entry in ItemResource.getDerivedValue");if(null===a.itemType)throw new Error("Column '"+s+"' doesn't have children in ItemResource.getDerivedValue");var c=n[s];if(null===c)return;if(void 0===(r=this.transaction.getLocalItemEntryByItemId(a.itemType,c)))throw new Error("Derived itemEntry "+a.itemType+":"+c+" couldn't be found");n=this.transaction.getItemChangesRecursively(r.id,!1)}return n},e.prototype.getDerivedValue=function(e,t){"string"==typeof t&&(t=this.columnUtil.parseConfigColumn(t));var r=this.getDerivedValues(e,t.slice(0,-1));if(void 0!==r)return r[t[t.length-1]]},e.prototype.clearItemEntry=function(e){this.entries.clear(e),delete this.itemChanges[e.id]},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)throw new Error("You should use fields[columnId] instead of derived['columnId>id'] to get the id of a derived item");for(var a={},c=0,u=e;c<u.length;c++){var l=u[c];null!==(p=this.getItemIdByColumn(l,t,r))&&(void 0===a[p]&&(a[p]=[]),a[p].push(l))}if(!s(a))return this.promiseService.when();var h=[];for(var p in a)h.push(+p);for(var d=[],f=0,m=o;f<m.length;f++){var y=m[f];d.push(y.id)}return this.fetchItemEntries(t.itemType,h,new L({columns:d})).then(function(){return n.resolveDerivedValues(e,o)},this.errorHandler.reject)},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.createItemEntry=function(e){var t=this.itemEntryFactory.construct(e.itemId,e.columns);return this.entries.add(t),t},e.prototype.getItemIdByColumn=function(e,t,r){return 0===t.level?void 0!==r&&void 0!==r.updated[e.id]?r.updated[e.id].changes.fields[t.path]:this.transaction.getChangesFromItemChanges(this.itemChanges[e.id])[t.path]:this.getDerivedValue(e,t.path)},e.prototype.expandColumnsWithCollectionColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();void 0!==t&&r.expandWithRequestColumns(e,t);for(var n=function(t){for(var n=0,o=t.collectionHandler.entries.getByItemType(e);n<o.length;n++){var i=o[n];r.expandWithRequestColumns(e,i.options.queryColumns),r.expandWithRequestColumns(e,i.options.columns)}},o=function(e){for(var t=0,r=e;t<r.length;t++){var i=r[t];n(i),o(i.children)}},i=0,s=this.transaction.getTransactionChain();i<s.length;i++){var a=s[i];n(a)}return o(this.transaction.children),r.get()[e]},e}(),ue=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)}}(),le=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v){var g=e.call(this,p,d,f,h,c,y,m,v)||this;return g.changesDeltaFactory=t,g.exceptionHandler=r,g.templateCache=n,g.columnExpansionFactory=o,g.columnHandler=i,g.columnSetFactory=s,g.columnSubsetCacheFactory=a,g.itemEntryService=u,g.keyService=l,g.transaction=v,g.deletedItems={},g.itemChanges={},g.itemResources={},g}return ue(t,e),t.prototype.copyTransactionItemEntryChanges=function(e,t){return{initial:this.apiFormatter.copyFields(e.initial,{},t.columns.main),changes:this.apiFormatter.copyFields(e.changes,{},t.columns.main)}},t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t),n=this.itemEntryService.getLocalDefaultValues();for(var o in n)t.fields[o]=n[o];var i=this.apiFormatter.copyFields(t.fields,{},t.columns.main);return this.itemChanges[r.id]={initial:t.fields,changes:i},this.itemChanges[r.id].initial.id=r.itemId,this.itemChanges[r.id].changes.id=r.itemId,r},t.prototype.formatRequest=function(e){var t=e.columns.main;return e.isLocal()?this.apiFormatter.formatRequestLocal(this.itemChanges[e.id].changes,t):this.apiFormatter.formatRequest(this.itemChanges[e.id].initial,this.itemChanges[e.id].changes,t)},t.prototype.createItems=function(e,t,r){for(var n,o=this,i=[],s=this.changesDeltaFactory.construct(),a=((n={})[e]=this.expandColumnsWithCollectionColumns(e),n),c=function(t){var n=u.keyService.getLocalId();i.push(u.templateCache.fetchTemplate(e,n,{},a,r).then(function(i){o.resolveLocal(s,e,n,r,i,function(){return!0},function(r,n){if(r===e)for(var o in t)n[o]=t[o]})},u.errorHandler.reject))},u=this,l=0,h=t;l<h.length;l++){c(h[l])}return this.promiseService.all(i).then(function(){return o.transaction.applyChangesDelta(s)})},t.prototype.clearItemEntry=function(t){e.prototype.clearItemEntry.call(this,t),delete this.itemResources[t.id]},t.prototype.addResource=function(e){var t=this.itemResources[e.entry.id];void 0===t&&(t=this.itemResources[e.entry.id]=[]),t.push(e)},t.prototype.clearResource=function(e){var t=this.itemResources[e.entry.id];if(void 0!==t){var r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&delete this.itemResources[e.entry.id]}},t.prototype.detectChanges=function(){for(var e in this.entries.entriesByEntryId)return!0;for(var t in this.itemChanges){if(this.detectEntryChanges(Number(t)))return!0}return!1},t.prototype.detectEntryChanges=function(e){var t=this.transaction.getLocalItemEntry(e),r=this.itemChanges[e];return this.apiFormatter.hasChanges(r.initial,r.changes,t.columns.main,!0)},t.prototype.processItemEntryChanges=function(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n=!1);var o=e.entry,i=e.changes;if(void 0===this.itemChanges[o.id])return null;null!==i.expandedColumns&&(o.columns=i.expandedColumns.merged);var s=this.itemChanges[o.id],a=this.apiFormatter.copyFields(s.changes,{},o.columns.main),c=this.apiFormatter.hasChanges(i.fields,s.changes,o.columns.main,!0);if(t?this.apiFormatter.copyFields(i.fields,s.changes,o.columns.main):this.apiFormatter.mergeCopyFields(s.initial,s.changes,i.fields,o.columns.main),r&&this.apiFormatter.copyFields(i.fields,s.initial,o.columns.main),void 0===i.fields.displayname){var u=this.itemEntryService.getDisplayName(o,s.changes);void 0!==u&&(s.changes.displayname=u)}if(c){var l=this.itemResources[o.id];if(void 0!==l)for(var h=function(e){try{e.options.onChange(e,a,function(t){return e.compareItemField(t,a)},n)}catch(e){p.exceptionHandler(e)}},p=this,d=0,f=l;d<f.length;d++){h(f[d])}}return a},t.prototype.cloneItemEntries=function(e,t,r){void 0===t&&(t={});var n=this.changesDeltaFactory.construct();this.itemEntryService.batchExpandConversionMap(e,t);for(var o=0,i=e;o<i.length;o++){var s=i[o];this.cloneItemEntry(n,s,{},t,r)}return this.transaction.applyChangesDelta(n)},t.prototype.cloneItemEntry=function(e,t,r,n,o){void 0===r&&(r={}),void 0===n&&(n={});var i=this.transaction.getLocalItemEntryChangesTuple(t.id),s=this.itemEntryService.expandConversionMap(t,n),a=this.transaction.getParent(t),c=null;if(null!==a){var u=this.itemEntryService.getConversionValue(a.itemType,a.itemId,n);c={itemType:a.itemType,itemId:u||a.itemId}}var l=this.apiFormatter.copyFields(i.changes.changes,{},t.columns.main),h=this.updateItemValues(l,c,t.columns.item,n);for(var p in h)l[p]=h[p];for(var p in r)l[p]=r[p];return void 0!==o&&o(t,l),e.setItemCreated(s,r,t.columns),s},t.prototype.fetchItemEntriesByQuery=function(e,t,r){return this.transaction.getServerCache().itemHandler.fetchItemEntriesByQuery(e,t,r)},t.prototype.fetchItemEntry=function(e,t,r){var n=this;if(!this.keyService.isLocalId(t))return this.transaction.getServerCache().itemHandler.fetchItemEntry(e,t,r);if(void 0===this.entries.get(e,t))return this.transaction.parent instanceof Ke?this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(e)):this.transaction.parent.itemHandler.fetchItemEntry(e,t,r);r.columns=this.expandColumnsWithCollectionColumns(e,r.columns);var o=this.changesDeltaFactory.construct(),i=this.columnSubsetCacheFactory.construct(r.columns);return this.fetchLocalItemEntryData(o,e,t,i,r).then(function(e){return n.transaction.applyChangesDelta(o).then(function(){return e},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.fetchNewItemEntry=function(e,t,r){var n=this;return void 0!==this.entries.get(e,t)?this.errorHandler.reject(this.itemEntryService.createExistingLocalItemError(e)):this.templateCache.fetchTemplate(e,t,r.templateOptions,r.templateColumns,r.parent).then(function(o){if(void 0!==n.entries.get(e,t))return n.errorHandler.reject(n.itemEntryService.createExistingLocalItemError(e));var i=n.changesDeltaFactory.construct();return n.resolveLocal(i,e,t,r.parent,o),n.transaction.applyChangesDelta(i)},this.errorHandler.reject)},t.prototype.fetchItemEntries=function(e,t,r){for(var n=[],o=[],i=0,s=t;i<s.length;i++){var a=s[i];this.keyService.isLocalId(a)?o.push(a):n.push(a)}return this.promiseService.all({remote:this.transaction.getServerCache().itemHandler.fetchItemEntries(e,n,r),local:this.fetchLocalItemEntries(e,o,r)}).then(function(e){return e.remote.concat(e.local)})},t.prototype.fetchTitle=function(e,t){var r=this,n=this.itemEntryService.getTitleField(e);return this.fetchItemEntry(e,t,new L({columns:[n]})).then(function(e){return r.transaction.getItemChangesRecursively(e.id,!1)[n]},this.errorHandler.reject)},t.prototype.resolveLocalItemEntry=function(e,t,r,n){var o=this;if(r.run(t.columns))return this.promiseService.when(t);var i=this.getColumnDifference(t,n.columns);return this.columnHandler.fetch(t.itemType,i).then(function(r){return o.expandLocalItemEntries(e,t.itemType,[t],i,r)},this.errorHandler.reject).then(function(){return t},this.errorHandler.reject)},t.prototype.createLocalEntries=function(e,t,r,n,o,i,s){var a=this;void 0===i&&(i=function(){return!0});var c=n.response,u={},l=function(t,r,h){var p={itemType:t,itemId:r},d=c.items[t][h].links;for(var f in d)if(d.hasOwnProperty(f)){void 0===u[f]&&(u[f]=a.columnSetFactory.construct(f,!0,n.responseColumns));for(var m=0,y=d[f];m<y.length;m++){var v=y[m],g=c.fetchObject(f,v);if(i(f,g)){var C=o[f][v],I=a.updateItemValues(g,p,u[f].item,o);for(var F in I)g[F]=I[F];void 0!==s&&s(f,g,o),e.setItemCreated(C,g,u[f],p),l(f,C,v)}}}};l(t,r,c.links[t][0])},t.prototype.expandLocalItemEntries=function(e,t,r,n,o){if(0===r.length)return this.promiseService.when(r);for(var i=this.columnExpansionFactory.construct(t,n,o),s=0,a=r;s<a.length;s++){var c=a[s],u=i.run(c.columns);null!==u&&this.expandLocalItemEntry(e,c,u)}return this.resolveDerivedValues(r,i.aggregateRootColumns())},t.prototype.updateItemValues=function(e,t,r,n){for(var o={},i=0,s=r;i<s.length;i++){var a=s[i],c=a.id,u=a.apiColumn,l=void 0;"link"===u.type&&void 0===e[c]?null!==t&&(l=t.itemId):l=this.itemEntryService.getConversionValue(u.itemType,e[c],n),void 0!==l&&(o[c]=l)}return o},t.prototype.fetchLocalItemEntryData=function(e,t,r,n,o){var i=this.entries.get(t,r);return void 0===i?this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(t)):this.resolveLocalItemEntry(e,i,n,o)},t.prototype.fetchLocalItemEntries=function(e,t,r){var n=this;r.columns=this.expandColumnsWithCollectionColumns(e,r.columns);for(var o=this.changesDeltaFactory.construct(),i=this.columnSubsetCacheFactory.construct(r.columns),s=[],a=[],c=0,u=t;c<u.length;c++){var l=u[c];if(void 0!==this.entries.get(e,l))s.push(this.fetchLocalItemEntryData(o,e,l,i,r));else{if(this.transaction.parent instanceof Ke)return this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(e));a.push(l)}}if(a.length>0){if(this.transaction.parent instanceof Ke)throw new Error("Tried looking for local entries on the serverCache");s.push(this.transaction.parent.itemHandler.fetchLocalItemEntries(e,a,r))}return this.promiseService.all(s).then(function(){return n.transaction.applyChangesDelta(o).then(function(){return t.map(function(t){return n.transaction.getLocalItemEntryByItemId(e,t)})},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.getColumnDifference=function(e,t){return this.columnUtil.mergeRequestColumns(e.columns.request,t).difference},t.prototype.resolveLocal=function(e,t,r,n,o,i,s){void 0===i&&(i=function(){return!0});var a=this.itemEntryService.createLocalConversionMap(t,r,!0,o.response),c=this.apiFormatter.copyFields(o.fields,{},o.columns.main),u=this.updateItemValues(c,n,o.columns.item,a);for(var l in u)c[l]=u[l];void 0!==s&&s(t,c,a),e.setItemCreated(r,c,o.columns,n),this.createLocalEntries(e,t,r,o,a,i,s)},t.prototype.expandLocalItemEntry=function(e,t,r){var n=r.difference.main;if(t.columns=r.merged,0!==n.length){var o=this.getLocalValues(t,n);s(o)&&e.setItemUpdated(t,o,r)}},t.prototype.getLocalValues=function(e,t){for(var r=this.transaction.getParent(e),n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),o={},i=0,s=t;i<s.length;i++){var a=s[i],c=a.id;if(void 0===n[c]){var u=a.apiColumn.type;o[c]="link"===u&&null!==r?r.itemId:this.apiFormatter.getDefaultValue(u)}}return o},t}(ce),he=function(){function e(e,t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k){this.core=e,this.columnCache=t,this.requestBufferManager=r,this.requestColumnExpansionFactory=n,this.queryMatcherFactory=o,this.authInterface=i,this.changesDeltaFactory=s,this.lockService=a,this.moduleChangesCompilationFactory=c,this.collectionResourceFactory=u,this.itemResourceFactory=l,this.templateCache=h,this.itemCacheFactory=p,this.collectionCacheFactory=d,this.errorHandler=f,this.exceptionHandler=m,this.promiseService=y,this.apiRequestService=v,this.columnExpansionFactory=g,this.columnHandler=C,this.columnSetFactory=I,this.columnSubsetCacheFactory=F,this.columnUtil=E,this.itemEntryFactory=S,this.itemEntryService=R,this.keyService=q,this.collectionEntryFactory=T,this.collectionEntryService=w,this.collectionMatcherFactory=b,this.queryParserFactory=H,this.queryService=M,this.apiFormatter=x,this.linkTreeService=k,this.children=[]}return e.prototype.createChild=function(e){var t=new Ie(this.core,this.columnCache,this.requestBufferManager,this.requestColumnExpansionFactory,this.queryMatcherFactory,this.authInterface,this.changesDeltaFactory,this.lockService,this.moduleChangesCompilationFactory,this.collectionResourceFactory,this.itemResourceFactory,this.templateCache,this.itemCacheFactory,this.collectionCacheFactory,this.errorHandler,this.exceptionHandler,this.promiseService,this.apiRequestService,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnSubsetCacheFactory,this.columnUtil,this.itemEntryFactory,this.itemEntryService,this.keyService,this.collectionEntryFactory,this.collectionEntryService,this.collectionMatcherFactory,this.queryParserFactory,this.queryService,this.apiFormatter,this.linkTreeService,this,e);return this.children.push(t),t},e.prototype.onChildDestroy=function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1)},e.prototype.getTransactionChain=function(){var e=[],t=this;do{e.push(t),t=t.parent}while(null!==t);return e},e.prototype.getCurrentCollectionEntryCache=function(){return this.collectionHandler.entries},e.prototype.getCurrentItemEntryCache=function(){return this.itemHandler.entries},e.prototype.getParentFromFields=function(e,t){if(void 0===t)return null;if(null!==e.columns.link)return{itemType:e.columns.link.apiColumn.itemType,itemId:t[e.columns.link.id]};var r=e.columns.response[e.itemType];return void 0!==r.itemtype&&void 0!==r.item?{itemType:t.itemtype,itemId:t.item}:null},e.prototype._applyChangesDelta=function(e){for(var t=this,r=this.changesDeltaFactory.constructInternalDelta(),n=[],o=[],i=function(e){var t=s.itemHandler.createItemEntry(e);n.push(t),r.setItemCreated(t,s.getChangesFromItemChanges(s.itemHandler.itemChanges[t.id])),o.push(function(e){return e.setItemDeleted(t)})},s=this,a=0,c=e.created;a<c.length;a++){i(c[a])}var u=function(t){var n=e.updated[t],i=l.itemHandler.processItemEntryChanges(n,!0);if(r.setItemUpdated(n.entry,n.changes.fields,n.changes.expandedColumns),null!==i&&o.push(function(e){return e.setItemUpdated(n.entry,i)}),null!==n.changes.parent&&r.setItemMoved(n.entry,n.changes.parent),l.itemHandler instanceof le){var s=l.itemHandler.deletedItems[n.entry.itemType];if(void 0===s)return"continue";var a=s.indexOf(n.entry);a>-1&&s.splice(a,1)}},l=this;for(var h in e.updated)u(h);return{result:{created:n,rollback:function(){for(var e=t.changesDeltaFactory.construct(),r=0,n=o;r<n.length;r++){(0,n[r])(e)}return t.applyChangesDelta(e)}},internalChangesDelta:r,rollbackFunctions:o}},e.prototype.fetchUpdatedDerivedValuesFromDelta=function(e){var t=[];for(var r in e.updated){for(var n=e.updated[r],o=[],i=0,s=n.entry.columns.root;i<s.length;i++){var a=s[i];n.changes.fields.hasOwnProperty(a.id)&&n.changes.fields[a.id]!==this.getChangesFromItemChanges(this.itemHandler.itemChanges[n.entry.id])[a.id]&&o.push(a)}0!==o.length&&t.push(this.itemHandler.resolveDerivedValues([n.entry],o,e))}return this.promiseService.all(t)},e}(),pe=function(){function e(e,t,r){this.queryMatcherFactory=e,this.transaction=t,this.getCollectionEntries=r,this.map={}}return e.prototype.expand=function(e,t){var r=this.queryMatcherFactory.construct(e.itemType,t,this.transaction.getParent(e));return this._expand(e,function(e){return r.matchQuery(e.query.object)})},e.prototype.processDelta=function(e){for(var t in e.deleted)for(var r=0,n=e.deleted[t];r<n.length;r++){var o=n[r];this._expand(o,function(){return!1})}var i=function(t){var r=e.created[t],n=s.queryMatcherFactory.construct(r.entry.itemType,r.fields,s.transaction.getParent(r.entry));s._expand(r.entry,function(e){return n.matchQuery(e.query.object)})},s=this;for(var a in e.created)i(a);var c=function(t){var r=e.moved[t];u._expand(r.entry,function(e){return e.matchParent(r.to.itemType,r.to.itemId)})},u=this;for(var a in e.moved)c(a);var l=function(t){var r=e.updated[t],n={},o=h.transaction.getItemChangesRecursively(Number(t),!1),i=function(e,t){var r=Object.getOwnPropertyDescriptor(e,t);void 0!==r?Object.defineProperty(n,t,r):n[t]=e[t]};for(var s in o)i(o,s);for(var s in r.changes.fields)i(r.changes.fields,s);var a=h.queryMatcherFactory.construct(r.entry.itemType,n,h.transaction.getParent(r.entry));h._expand(r.entry,function(e){return a.matchQuery(e.query.object)})},h=this;for(var a in e.updated)l(a);return this},e.prototype.hasFittingItems=function(e){for(var t in e)if(!0===e[t].isMatch)return!0;return!1},e.prototype._expand=function(e,t){for(var r=this.map,n=e.itemId,o=0,i=this.getCollectionEntries(e.itemType);o<i.length;o++){var s=i[o],a=s.id,c=void 0;void 0===r[a]&&(r[a]={collection:s,matches:{}}),void 0===(c=r[a].matches)[n]&&(c[n]={item:e,isMatch:t(s)})}return this},e}(),de=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)}}(),fe=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return de(t,e),t.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},t}(pe),me=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)}}(),ye=function(e){function t(t,r,n,o){var i=e.call(this,r,n,o)||this;return i.apiRequestService=t,i}return me(t,e),t.prototype.removeFromAndAddToCollections=function(e){var t=this;void 0===e&&(e=!1);var r=function(r){var o,i=n.map[r],s=i.collection,a=n.groupItemEntries(i.matches);n.transaction.collectionHandler.removeItemEntriesFromCollectionChanges(s,a.notFitting,e),n.transaction.collectionHandler.addItemEntriesToCollectionChanges(s,a.fitting,e),a.maybe.length>0&&n.apiRequestService.query(s.itemType,s.query.object,(o={},o[s.itemType]=["id"],o)).then(function(r){t.transaction.collectionHandler.addItemEntriesToCollectionChanges(s,a.maybe.filter(function(e){return r.links[s.itemType].indexOf(e.itemId)>-1}),e)})},n=this;for(var o in this.map)r(o)},t.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var o in e){var i=e[o],s=i.item,a=i.isMatch;!0===a?t.push(s):!1===a?r.push(s.itemId):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},t}(fe),ve=function(){function e(e,t,r){this.errorHandler=e,this.exceptionHandler=t,this.promiseService=r,this.callbacks={onBeforeSave:[],onSaveSuccess:[]}}return e.prototype.registerCallback=function(e,t,r,n,o){var i=this;return void 0===n&&(n="always"),void 0===o&&(o=100),this.getPriorityLevel(e,o)[t]={callback:r,condition:n},function(){delete i.getPriorityLevel(e,o)[t]}},e.prototype.executeCallbacks=function(e,t,r){for(var n=this.callbacks[e],o=r?"onClose":"skipOnClose",i=this.promiseService.when(),s=0,a=n;s<a.length;s++){var c=a[s];i=i.then(this.executeCallbacksPriorityLevel(c[1],o,t),this.errorHandler.reject)}return i},e.prototype.getPriorityLevel=function(e,t){for(var r,n=this.callbacks[e],o=0;o<n.length;o++){var i=n[o];if(!(i[0]<t))return i[0]===t?i[1]:(r={},n.splice(o,0,[t,r]),r)}return r={},n.push([t,r]),r},e.prototype.executeCallbacksPriorityLevel=function(e,t,r){var n=this;return function(){var o={};for(var i in e){var s=e[i];if(s.condition===t||"always"===s.condition)try{o[i]=r(s.callback)}catch(e){n.exceptionHandler(e)}}return n.promiseService.all(o)}},e}(),ge=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)}}(),Ce=function(){return(Ce=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Ie=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D,O,P){var _=e.call(this,t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D)||this;return _.id=P,_.tabRequestParameters={},_.isSaving=!1,_.hasChanges=!1,_.changesInterval=null,_.parent=O,_.itemHandler=new le(a,y,p,C,I,F,E,m,q,T,v,S,k,R,d,o,_),_.collectionHandler=new pt(o,S,E,C,a,f,b,H,I,m,_.itemHandler,T,v,y,_),_.eventHandler=new ve(m,y,v),_}return ge(t,e),t.prototype.destroy=function(){this.parent.onChildDestroy(this)},t.prototype.createChangesDelta=function(){return this.changesDeltaFactory.construct()},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;for(var o in void 0===t&&(t=!1),void 0===r&&(r=!1),e.updated){var i=e.updated[o];this.itemHandler.processItemEntryChanges(i,t,!0,r)}for(var s in e.deleted)for(var a=0,c=e.deleted[s];a<c.length;a++){var u=c[a];if(this.itemHandler.entries.clear(u),delete this.itemHandler.itemChanges[u.id],delete this.itemHandler.itemResources[u.id],void 0!==this.itemHandler.deletedItems[u.itemType]){var l=this.itemHandler.deletedItems[u.itemType].indexOf(u);-1!==l&&this.itemHandler.deletedItems[u.itemType].splice(l,1)}}new ye(this.apiRequestService,this.queryMatcherFactory,this,function(e){return n.collectionHandler.getAllCollectionsByItemType(e)}).processDelta(e).removeFromAndAddToCollections(r);for(var h=0,p=this.children;h<p.length;h++){p[h].applyChangesFromParent(e)}this.hasChanges=!1,this.detectChanges()},t.prototype.applyChangesDelta=function(t){var r=this;return 0!==t.created.length||s(t.updated)||s(t.deleted)?this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var n=e.prototype._applyChangesDelta.call(r,t),o=n.result,i=n.internalChangesDelta,s=n.rollbackFunctions;for(var a in t.deleted)for(var c=function(e){r.itemHandler.entries.clear(e);var n=r.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete r.itemHandler.itemChanges[e.id],delete r.itemHandler.itemResources[e.id],void 0===r.itemHandler.deletedItems[e.itemType]&&(r.itemHandler.deletedItems[e.itemType]=[]),r.itemHandler.deletedItems[e.itemType].push(e),i.setItemDeleted(e),s.push(function(t){t.setItemUpdated(e,n.changes)})},u=0,l=t.deleted[a];u<l.length;u++){c(l[u])}new ye(r.apiRequestService,r.queryMatcherFactory,r,function(e){return r.collectionHandler.getAllCollectionsByItemType(e)}).processDelta(i).removeFromAndAddToCollections();for(var h=0,p=r.children;h<p.length;h++){p[h].applyChangesFromParent(i)}return r.hasChanges=!1,r.detectChanges(),o}):this.promiseService.when({created:[],rollback:Nt})},t.prototype.getServerCache=function(){return this.parent.getServerCache()},t.prototype.getParent=function(e,t,r){var n;if(void 0===t&&(t=!1),void 0!==r)n=r;else{var o=this.itemHandler.itemChanges[e.id];void 0!==o&&(n=o[t?"initial":"changes"])}if(void 0!==n){var i=this.getParentFromFields(e,n);if(null!==i)return i}return this.parent.getParent(e,t)},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);return void 0!==r&&void 0!==n?t?this.apiFormatter.copyFields(r.changes,{},n.columns.main):r.changes:this.parent.getItemChangesRecursively(e,t)},t.prototype.clearItemResource=function(e){return this.itemHandler.clearResource(e)},t.prototype.clearCollectionResource=function(e){return this.collectionHandler.clearResource(e)},t.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},t.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},t.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=window.setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},t.prototype.save=function(e,t,r,n){var o,i=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 i.eventHandler.executeCallbacks("onBeforeSave",function(e){return e(i)},e)},this.errorHandler.reject).then(function(){return i.tabRequestParameters=Ce({},i.tabRequestParameters,t),i.parent.applyChangesFromChild(i,r,n)}).then(function(t){return o=t,i.tabRequestParameters={},i.isLockable()&&i.lockService.clearLock(i.rootItem),i.hasChanges=!1,i.eventHandler.executeCallbacks("onSaveSuccess",function(e){return e(i,o)},e)},this.errorHandler.reject).then(function(){return e||i.enableChangesWatcher(),i.isSaving=!1,o},this.errorHandler.reject).catch(function(e){return i.isSaving=!1,i.errorHandler.reject(e)}))},t.prototype.detectChanges=function(){return!!this.hasChanges||(this.itemHandler.detectChanges()?this.hasChanges=!0:this.hasChanges=!1)},t.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},t.prototype.clearItemEntry=function(e){return this.itemHandler.clearItemEntry(e)},t.prototype.clearCollection=function(e){return this.collectionHandler.clearEntry(e.entry)},t.prototype.onBeforeSave=function(e,t,r,n){return this.eventHandler.registerCallback("onBeforeSave",e,t,r,n)},t.prototype.onSaveSuccess=function(e,t,r,n){return this.eventHandler.registerCallback("onSaveSuccess",e,t,r,n)},t.prototype.getModuleChanges=function(){if(void 0===this.rootItem)throw new Error("No root item for transaction cache "+this);return this.moduleChangesCompilationFactory.construct(this).process()},t.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])}},t.prototype.cloneCollection=function(e,t,r){var n=t.parent;if(null===n||void 0===n)throw new Error("Parent required for cloneCollection");return this.createCollectionResource(this.collectionHandler.cloneCollectionEntry(e.entry,n,r),t)},t.prototype.cloneItem=function(e,t){var r=this,n=this.changesDeltaFactory.construct();return this.itemHandler.cloneItemEntry(n,e.entry),this.applyChangesDelta(n).then(function(e){var n=e.created[0];return r.createItemResource(n,t,!1)})},t.prototype.getAllLinkCollections=function(e,t,r){var n,o=this;return this.apiRequestService.query(e,{},(n={},n[e]=["id"],n)).then(function(n){return o.getLinkCollections(e,n.links[e],t,r)},this.errorHandler.reject)},t.prototype.getLinkCollectionsFromDef=function(e,t,r){var n=this;return this.collectionHandler.fetchLinkedCollectionEntries(e,t,r.itemType,r.options.entry).then(function(e){return n.createCollectionResources(e,r.options.resource)},this.errorHandler.reject)},t.prototype.getLinkCollections=function(e,t,r,n){var o=this;return this.collectionHandler.fetchLinkedCollectionEntries(e,t,r,new J(n)).then(function(e){return o.createCollectionResources(e,n)},this.errorHandler.reject)},t.prototype.getCollectionFromDef=function(e){var t=this;return this.collectionHandler.fetchCollectionEntry(e.itemType,e.options.entry).then(function(r){return t.createCollectionResource(r,e.options.resource)},this.errorHandler.reject)},t.prototype.getCollection=function(e,t){var r=this;return this.collectionHandler.fetchCollectionEntry(e,new J(t)).then(function(e){return r.createCollectionResource(e,new K(t))},this.errorHandler.reject)},t.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:new J(t),resource:new K(t)}}},t.prototype.getLinkCollectionsDef=function(e,t,r){return{itemType:e,linkField:t,options:{entry:new J(r),resource:new K(r)}}},t.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.itemHandler.entries.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)},t.prototype.getDuplicateById=function(e,t,r,n,o){return void 0===r&&(r={}),void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=t),this.getNewResourceWithId(e,this.keyService.getLocalDuplicateId(),r,n,o)},t.prototype.getNewResourceWithId=function(e,t,r,n,o){var i=this;return void 0===n&&(n=!1),r.edit=!0,this.itemHandler.fetchNewItemEntry(e,t,new L(r)).then(function(s){for(var a,c={},u=0,l=s.created;u<l.length;u++){var h=l[u];h.itemType!==e||h.itemId!==t?(void 0===c[h.itemType]&&(c[h.itemType]=[]),c[h.itemType].push(h)):a=h}if(void 0===a)throw new Error("The ItemEntry with the requested ItemId was not in the template response");var p=i.createItemResource(a,r,o,!0);return n?{main:p,linked:i.processLinkedItems(c,r)}:p},this.errorHandler.reject)},t.prototype.getNewResource=function(e,t,r,n){return void 0===t&&(t={}),this.getNewResourceWithId(e,this.keyService.getLocalId(),t,r,n)},t.prototype.getItemsByQuery=function(e,t,r){var n=this;void 0===r&&(r={});var o=new L(r);return this.itemHandler.fetchItemEntriesByQuery(e,t,o).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},t.prototype.getItemsById=function(e,t,r){var n=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntries(e,t,new L(r)).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},t.prototype.getItemById=function(e,t,r,n){var o=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntry(e,t,new L(r)).then(function(e){return o.createItemResource(e,r,n)},this.errorHandler.reject)},t.prototype.fetchTitle=function(e,t){return this.itemHandler.fetchTitle(e,t)},t.prototype.applyChangesFromChild=function(e,t,r){var n=this,o=this.linkTreeService.get(),i=e.getDelta();for(var s in i.moved){var a=i.moved[s];i.setItemUpdated(a.entry,{},null,a.to),delete i.moved[s]}for(var s in i.updated){a=i.updated[s];void 0===this.itemHandler.itemChanges[s]?this.itemHandler.itemChanges[s]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry):this.itemHandler.processItemEntryChanges(a,!0)}for(var s in i.created){a=i.created[s];this.itemHandler.entries.add(a.entry),e.itemHandler.entries.clear(a.entry);var c=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry),u=this.itemEntryService.getDisplayName(a.entry,c.changes);if(void 0!==u&&(c.changes.displayname=u),void 0!==this.rootItem){var l=o[this.rootItem.itemType][a.entry.itemType];void 0!==l&&(l.type===k.ITEMTABLE?(c.changes.itemtype=this.rootItem.itemType,c.changes.item=this.rootItem.itemId):l.type===k.DIRECT&&(c.changes[l.field]=this.rootItem.itemId))}}for(var h in i.deleted){void 0===this.itemHandler.deletedItems[h]&&(this.itemHandler.deletedItems[h]=[]);for(var p=0,d=i.deleted[h];p<d.length;p++){var f=d[p];f.isLocal()||(this.itemHandler.entries.clear(f),this.itemHandler.deletedItems[h].push(f))}}return this.hasChanges=!0,this.expandItemsFromDelta(i).then(function(){new ye(n.apiRequestService,n.queryMatcherFactory,n,function(e){return n.collectionHandler.getAllCollectionsByItemType(e)}).processDelta(i).removeFromAndAddToCollections();for(var t=0,r=n.children;t<r.length;t++){var o=r[t];o!==e&&o.applyChangesFromParent(i)}return i.itemIdConversionMap})},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);return void 0!==t?t:this.parent.getLocalItemEntry(e)},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);return void 0!==r?r:this.parent.getLocalItemEntryByItemId(e,t)},t.prototype.getLocalCollectionEntry=function(e){var t=this.collectionHandler.entries.getByEntryId(e);return void 0!==t?t:this.parent.getLocalCollectionEntry(e)},t.prototype.getDelta=function(){var e=this.changesDeltaFactory.constructInternalDelta();for(var t in this.itemHandler.itemChanges){var r=this.getLocalItemEntryChangesTuple(Number(t));if(this.itemHandler.entries.contains(r.entry.itemType,r.entry.itemId)&&r.entry.isLocal())e.setItemCreated(r.entry,r.changes.changes);else{var n=this.getParent(r.entry);if(null!==n){var o=this.getParent(r.entry,!0);this.itemEntryService.matchParent(o,n)||e.setItemMoved(r.entry,n)}this.apiFormatter.hasChanges(r.changes.initial,r.changes.changes,r.entry.columns.main)&&e.setItemUpdated(r.entry,r.changes.changes)}}for(var i in this.itemHandler.deletedItems)e.setItemsDeleted(this.itemHandler.deletedItems[i]);return e},t.prototype.createItemResource=function(e,t,r,n){void 0===r&&(r=!1),r&&(this.rootItem=e),void 0===this.itemHandler.itemChanges[e.id]&&(this.itemHandler.itemChanges[e.id]={initial:this.getItemChangesRecursively(e.id),changes:this.getItemChangesRecursively(e.id)});var o=this.itemResourceFactory.construct(e,t,this,n);return this.itemHandler.addResource(o),o},t.prototype.createItemResources=function(e,t){for(var r=this.itemResourceFactory.getConstructor(t,this),n=[],o=0,i=e;o<i.length;o++){var s=i[o];void 0===this.itemHandler.itemChanges[s.id]&&(this.itemHandler.itemChanges[s.id]={initial:this.getItemChangesRecursively(s.id,!0),changes:this.getItemChangesRecursively(s.id,!0)});var a=r(s);n.push(a),this.itemHandler.addResource(a)}return n},t.prototype.processLinkedItems=function(e,t){var r={};for(var n in e)r[n]=this.createItemResources(e[n],t);return r},t.prototype.createCollectionResource=function(e,t){if(void 0===this.collectionHandler.collectionChanges[e.id]){this.collectionHandler.collectionChanges[e.id]=[];for(var r=new ye(this.apiRequestService,this.queryMatcherFactory,this,function(){return[e]}),n=0,o=this.getTransactionChain();n<o.length;n++)for(var i=0,s=o[n].itemHandler.entries.getByItemType(e.itemType);i<s.length;i++){var a=s[i],c=this.getItemChangesRecursively(a.id,!1);r.expand(a,c)}r.removeFromAndAddToCollections()}var u=this.collectionResourceFactory.construct(e,t,this);return this.collectionHandler.addResource(u),u},t.prototype.getChangesFromItemChanges=function(e){return e.changes},t.prototype.createCollectionResources=function(e,t){var r={};for(var n in e)r[n]=this.createCollectionResource(e[n],t);return r},t.prototype.expandItemsFromDelta=function(e){var t={},r={},n=function(e){void 0===t[e.itemType]&&(t[e.itemType]=[]),t[e.itemType].push(e)};for(var o in e.created)n(e.created[o].entry);for(var o in e.updated)n(e.updated[o].entry);for(var i in t){var s=this.collectionHandler.getAllCollectionsByItemType(i);if(0!==s.length){for(var a=this.requestColumnExpansionFactory.construct(),c=0,u=s;c<u.length;c++){var l=u[c];a.expand(l.columns)}r[i]=a.get()[i]}}var h=[];for(var i in r)h.push(this.itemHandler.expandLocalItemEntries(e,i,t[i],r[i],this.columnCache.retrieve(i,r[i]).cached));return this.promiseService.all(h)},t}(he);!function(e){e.MAYBE="maybe"}(ae||(ae={}));var Fe,Ee,Se=function(){function e(e,t){this.queryMatcherFactory=e,this.transaction=t,this.entries={}}return e.prototype.getByEntryId=function(e){for(var t in this.entries){var r=this.entries[t][e];if(void 0!==r)return r}},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.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],s=this.transaction.collectionHandler.collectionChanges[i.id];void 0!==s&&(s.some(function(e){return e.itemId==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 a=n[s],c=i.matchQuery(a.query.object);!0===c?o.fitting.push(a):c===ae.MAYBE?o.maybe.push(a):o.notfitting.push(a)}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||!(this.transaction instanceof Ie))return n;for(var o in r)for(var i=0,s=this.transaction.collectionHandler.collectionResources[o];i<s.length;i++){var a=s[i];a.options.resourceKey===t&&n.push(a)}return n},e}(),Re=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.createUnfoundLocalCollectionError=function(e){return{message:"A local collection of type "+e+" could not be found"}},e.prototype.cloneOptions=function(e,t){var r=new J(e);return r.queryParams=this.cloneQueryParams(e.queryParams),r.parent=t,r},e.prototype.processOptions=function(e){return new J(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=[]),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 a=0;a<e.length;a++)e[a]=r[a];return n},e}(),qe=function(){function e(){}return e.prototype.processOptions=function(e){return new K(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}(),Te=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 a=[];this.retrieveColumns(s.itemType,i.children,a,n),0!==a.length&&r.push(((o={})[i.id]=a,o))}}else r.push(t)},e.prototype.getColumn=function(e,t){var r=this.cache[e];if(void 0!==r)return r[t]},e}(),we=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[a(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.columnInfoFactory.constructFromRootMap(r)},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}(),be=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}(),He=">",Me=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+He+r,this.tailPath=0===t.level?r:t.tailPath+He+r)}return e.prototype.setChildren=function(e,t){return this.itemType=e,this.children=t,this.isLeaf=!1,this},e}(),xe={},ke=0,De=function(){function e(e,t,r){this.columnUtil=e,this.columnSetFactory=t,this.itemType=r,this.id=++ke,this.response=xe,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=[]}return e.prototype.groupColumnInfo=function(e){var t=this.columnUtil,r=e.apiColumn,n=null!==e.parent;n?this.derived.push(e):(this.main.push(e),"link"===r.type&&(this.link=e),this[t.isItemColumn(r)?"item":"notItem"].push(e),e.isLeaf||this.root.push(e)),t.isFormattedColumn(r)&&this.formatted[n?"derived":"main"].push(e),t.isFilteredColumn(r)&&this.filtered.push(e),t.isSearchableColumn(r)&&this.searchable.push(e),t.isCustomColumn(r)&&this.custom.push(e),e.isLeaf&&this.leaf.push(e)},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.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.getMergedColumnSet=function(e,t,r){var n=this.columnSetFactory.construct(this.itemType,e.merged,t);return n.requestColumnsTrue=this.requestColumnsTrue||r,n},e.prototype.mergeRequestColumns=function(e){return this.columnUtil.mergeRequestColumns(this.request,e)},e.prototype.mergeResponseColumns=function(e){return this.columnUtil.mergeResponseColumns(this.response,e).merged},e.prototype.merge=function(e){return this.getMergedColumnSet(this.mergeRequestColumns(e.request),this.mergeResponseColumns(e.response),e.requestColumnsTrue)},e.prototype.expand=function(e,t,r){var n=this.mergeRequestColumns(e),o=this.mergeResponseColumns(r);return{merged:this.getMergedColumnSet(n,o,t),difference:this.columnSetFactory.construct(this.itemType,n.difference,o,!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}(),Pe=function(){function e(e){this.linkTreeService=e}return e.prototype.getColumnsFromLink=function(e,t){var r=this.linkTreeService.get()[e][t],n=[];switch(r.type){case k.DIRECT:n.push(r.field);break;case k.ITEMTABLE:n.push("itemtype"),n.push("item")}return n},e.prototype.getColumnPath=function(e,t){for(var r="",n="",o=0,i=e;o<i.length;o++){n+=r+i[o].id,r=He}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=0,r=e;t<r.length;t++){var n=r[t];if(this.parseRequestColumn(n).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],a=this.parseRequestColumn(s),c=a.children,u=r[e];if(void 0===u)return!1;if(void 0===(i=u[a.id]))return!1;if(c.length>0&&!this.responseColumnsAvailable(i.itemType,c,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],a=this.mergeRequestColumn(s,r);null!==a&&n.push(a)}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=[],a=0,c=o.children;a<c.length;a++){var u=c[a],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)b(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(He)},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}(),_e=function(){function e(e,t,r,n,o,i){void 0===i&&(i=!1),this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r,this.compilation=n,this.transaction=o,this.breakupByParent=i,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.transaction.collectionHandler.getCollectionMatcher()}},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 a=e[i][s],c=a.entry,u=d(this.compilation,[i,c.itemId]),l=n.items[i][c.itemId]={},h=d(this.transaction.tabRequestParameters,[i,c.itemId]);if(null!==t&&(n.parentId[c.itemId]=t),r.columns.expand(c.columns),o[i][s]=c,l.values=this.apiFormatter.formatRequestLocal(a.fields,c.columns.main),l.parameters=h,void 0!==u){var p=l.links={};for(var f in u)for(var m in p[f]=[],u[f])p[f].push(parseInt(m,10));this.extendRequest(u,null,r)}}},e}();!function(e){e.OR="OR",e.AND="AND"}(Fe||(Fe={})),function(e){e.EQUALS="=",e.NOT_EQUALS="!=",e.LESS_THAN="<",e.MORE_THAN=">",e.LESS_OR_EQUAL_THAN="<=",e.EQUAL_OR_MORE_THAN=">=",e.IN="IN"}(Ee||(Ee={}));var je,Le,Ae=function(){function e(e){this.query=e}return 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.custom)return this.parseCustomQuery(e.custom,e.parameters,e.not);if(void 0!==e.search)return this.parseSearchQuery(e.search,e.not);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator,e.not);if(void 0!==e.itemType)return this.parseSubFieldQuery(e.key,e.itemType,e.field,e.query,e.not);if(void 0!==e.key)return"object"==typeof e.query?this.parseSubQuery(e.key,e.query,e.not):this.parseSimpleQuery(e.key,e.value,e.comparator,e.not);var t=a(e);if(null===t)return this.parseEmptyQuery();var r=e[t];return null!==r&&"object"==typeof r&&r.constructor===Object?this.parseSubQuery(t,r,!1):this.parseSimpleQuery(t,r,e.comparator,e.not)},e}(),Be=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)}}(),Qe=function(e){function t(t,r,n){var o=e.call(this,n)||this;return o.columnUtil=t,o.itemType=r,o}return Be(t,e),t.prototype.parseEmptyQuery=function(){return[]},t.prototype.parseSubQuery=function(e,t,r){var n;return void 0===r&&(r=!1),[(n={},n[e]=this.parse(t),n)]},t.prototype.parseSubFieldQuery=function(e,t,r,n,o){return[]},t.prototype.parseSearchQuery=function(e,t){return[]},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),[]},t.prototype.parseSimpleQuery=function(e,t,r,n){return[e]},t.prototype.parseLinkedToQuery=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),this.columnUtil.getColumnsFromLink(e,this.itemType)},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.reduce(function(e,r){return e.concat(t.parse(r))},[])},t}(Ae),Ue=function(){function e(e,t,r,n,o){this.collectionEntryService=e,this.columnUtil=t,this.requestColumnExpansionFactory=r,this.transaction=o,this.collectionChanges={},this.entries=n.construct(this.transaction)}return e.prototype.createCollectionEntry=function(e,t){var r=this.transaction.core.collectionEntryFactory.construct(e,t);return this.entries.add(r),r},e.prototype._addItemEntriesToCollectionChanges=function(e,t,r,n){if(0!==t.length){var o=this.collectionChanges[e.id];if(void 0!==o){for(var i=[],s=0,a=t;s<a.length;s++){var c=a[s];-1!==o.indexOf(c)||r(c)||(o.push(c),i.push(c))}return this.handleAddedItemEntriesCallback(e,i,n)}}},e.prototype.removeItemEntriesFromCollectionChanges=function(e,t,r){if(void 0===r&&(r=!1),0===t.length)return[];var n=this.collectionChanges[e.id];if(void 0!==n){var o=this.collectionEntryService.filterArray(n,function(e){return!c(e.itemId,t)});return this.handleRemovedItemEntriesCallback(e,o,r)}},e.prototype.expandColumnsWithQueryColumns=function(e,t,r){var n=new Qe(this.columnUtil,e,r);if(t.queryColumns=n.parse(),!0!==t.columns){var o=this.requestColumnExpansionFactory.construct();o.expandWithRequestColumns(e,t.columns),o.expandWithRequestColumns(e,t.queryColumns),t.columns=o.get()[e]}},e}(),Ve=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(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f){var m=e.call(this,a,d,n,s,f)||this;return m.columnSubsetCacheFactory=t,m.requestBufferManager=r,m.columnExpansionFactory=o,m.apiRequestService=i,m.collectionMatcherFactory=c,m.errorHandler=u,m.itemHandler=l,m.promiseService=h,m.queryService=p,m.transaction=f,m}return Ve(t,e),t.prototype.getCollectionMatcher=function(){var e=this;return this.collectionMatcherFactory.construct(this.transaction,function(t){return e.entries.getByItemType(t)})},t.prototype.fetchCollectionEntry=function(e,t){var r=this.collectionEntryService.createQuery(t);this.expandColumnsWithQueryColumns(e,t,r.object);var n=this.columnSubsetCacheFactory.construct(t.columns);return this.fetchCollectionData(e,n,t,r)},t.prototype.fetchLinkedCollectionEntries=function(e,t,r,n){var o={};S(t)&&(t=t());for(var i=0,s=t;i<s.length;i++){var a=s[i],c=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:a}),u=this.collectionEntryService.createQuery(c);this.expandColumnsWithQueryColumns(r,c,u.object);var l=this.columnSubsetCacheFactory.construct(c.columns);o[a]=this.fetchCollectionData(r,l,c,u)}return this.promiseService.all(o)},t.prototype.extendCollectionEntry=function(e,t){var r,n,o=e.extendQuery(t).object,i=this.queryService.addAndCondition(o,this.queryService.createNotIn(this.collectionChanges[e.id].map(function(e){return e.itemId})));return this.expandColumnsWithQueryColumns(e.itemType,e.options,o),n=null!==e.options.limit?this.apiRequestService.requestSkeleton({requestType:"query",itemType:e.itemType,columns:(r={},r[e.itemType]=e.options.columns,r),query:o,limit:e.options.limit}):this.requestBufferManager.fetchByQuery(e.itemType,i,e.options.columns),e.promise=n,n.then(function(){delete e.promise},this.errorHandler.reject),n.then(function(){return e})},t.prototype.expandCollectionEntries=function(e,t,r,n){var o=this;if(0===n.length)return this.promiseService.when(r);var i=[];for(var s in r){var a=r[s].entry;i.push(a.parent.itemId)}return this.itemHandler.fetchLinkedItemEntriesData(e,i,t,null,n).then(function(e){for(var s=o.columnExpansionFactory.construct(t,n,e.fetchColumnsObject()),a=0,c=i;a<c.length;a++){var u=c[a];r[u].entry.expandColumns(s)}return r})},t.prototype.extendCollectionEntries=function(e,t,r,n,o){if(!s(o))return this.promiseService.when();var i=[],a=[];for(var c in r.queryParams=n(r.queryParams),o){var u=o[c].entry;u.extendQuery(n),i.push(u.parent.itemId),a=a.concat(this.collectionChanges[u.id].map(function(e){return e.itemId}))}return this.itemHandler.fetchLinkedItemEntriesData(e,i,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(a)),r.columns).then(function(){},this.errorHandler.reject)},t.prototype.addItemEntriesToCollectionChanges=function(t,r,n){void 0===n&&(n=!1),e.prototype._addItemEntriesToCollectionChanges.call(this,t,r,function(e){return e.isLocal()},n)},t.prototype.expandCollectionEntry=function(e,t){var r=this,n=e.columns.mergeRequestColumns(t),o=n.merged,i=n.difference;if(!0!==i&&0===i.length)return this.promiseService.when(e);var s=e.itemType;return(null!==e.options.limit?this.apiRequestService.requestSkeleton({requestType:"query",itemType:s,columns:o,query:e.query.object,limit:e.options.limit}):this.requestBufferManager.fetchByQuery(e.itemType,[e.query.object,e.query.string],o)).then(function(t){var n=r.columnExpansionFactory.construct(s,o,t.fetchColumnsObject());return e.expandColumns(n),n},this.errorHandler.reject)},t.prototype.handleAddedItemEntriesCallback=function(e,t){t.length},t.prototype.handleRemovedItemEntriesCallback=function(e,t){t.length},t.prototype.fetchCollectionData=function(e,t,r,n){var o,i=this,s=this.entries.getByQuery(e,n);return null!==s&&t.run(s.columns)?this.promiseService.when(s):(null!==r.limit?this.apiRequestService.requestSkeleton({requestType:"query",itemType:e,columns:(o={},o[e]=r.columns,o),query:r.query,limit:r.limit}).then(function(e){return i.transaction.processResponse(e,!1,!1),e},this.errorHandler.reject):this.requestBufferManager.fetchByQuery(e,[n.object,n.string],t.requestColumns)).then(function(o){if(null===(s=i.entries.getByQuery(e,n)))(s=i.createCollectionEntry(e,r)).columns=i.transaction.core.columnSetFactory.constructFromResponse(e,o.fetchColumnsObject());else{var a=i.columnExpansionFactory.construct(e,t.requestColumns,o.fetchColumnsObject());s.expandColumns(a)}return s})},t}(Ue),We=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)}}(),Ye=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p){var d=e.call(this,a,c,u,s,i,h,l,p)||this;return d.requestBufferManager=t,d.queryParserFactory=r,d.queryService=n,d.columnSubsetCacheFactory=o,d.transaction=p,d.itemChanges={},d}return We(t,e),t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t);return this.itemChanges[r.id]=t.fields,r},t.prototype.processItemEntryChanges=function(e,t,r,n){var o=e.entry,i=e.changes;void 0===this.itemChanges[o.id]&&(this.itemChanges[o.id]={}),null!==i.expandedColumns&&(o.columns=i.expandedColumns.merged);var s=this.apiFormatter.copyFields(this.itemChanges[o.id],{},o.columns.main);return this.apiFormatter.copyFields(i.fields,this.itemChanges[o.id],o.columns.main),void 0!==i.fields.id&&(o.itemId=i.fields.id),s},t.prototype.copyTransactionItemEntryChanges=function(e,t){return this.itemChanges[t.id]=this.apiFormatter.copyFields(e.changes,{},t.columns.main)},t.prototype.fetchItemEntry=function(e,t,r){var n=this;return r.columns=this.expandColumnsWithCollectionColumns(e,r.columns),this.fetchItemEntryData(e,t,this.columnSubsetCacheFactory.construct(r.columns)).then(function(){return n.entries.get(e,t)},this.errorHandler.reject)},t.prototype.fetchItemEntriesByQuery=function(e,t,r){var n=this;return r.columns=this.expandColumnsWithCollectionColumns(e,r.columns),this.requestBufferManager.fetchByQuery(e,this.queryParserFactory.construct(this.queryService.addParentCondition(t,r.parent)).parse(),r.columns).then(function(t){for(var r=[],o=0,i=t.links[e];o<i.length;o++){var s=i[o],a=n.entries.get(e,s);void 0!==a&&r.push(a)}return r},this.errorHandler.reject)},t.prototype.fetchItemEntries=function(e,t,r){var n=this;r.columns=this.expandColumnsWithCollectionColumns(e,r.columns);for(var o=this.columnSubsetCacheFactory.construct(r.columns),i=[],s=0,a=t;s<a.length;s++){var c=a[s];i.push(this.fetchItemEntryData(e,c,o))}return this.promiseService.all(i).then(function(){for(var r=[],o=0,i=t;o<i.length;o++){var s=i[o];r.push(n.entries.get(e,s))}return r},this.errorHandler.reject)},t.prototype.fetchLinkedItemEntriesData=function(e,t,r,n,o){return null===n?this.requestBufferManager.fetchByIds(e,t,o):this.requestBufferManager.fetchByQuery(r,this.queryParserFactory.construct(this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}})).parse(),o)},t.prototype.processApiResponse=function(e,t,r,n,o,i){var s=this.entries.get(r,n),a=t.fetchObject(r,n);if(void 0===a)throw new Error("Fields not found in response for "+r+":"+n);void 0===s?e.setItemCreated(n,a,o):e.setItemUpdated(s,a,i.run(s.columns))},t.prototype.fetchItemEntryData=function(e,t,r){var n=this.entries.get(e,t);return void 0!==n&&r.run(n.columns)?this.promiseService.when():this.requestBufferManager.fetchById(e,t,r.requestColumns).then(function(){},this.errorHandler.reject)},t}(ce),Je=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)}}(),Ke=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D,O){var P=e.call(this,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,I,F,E,S,R,q,T,w,b,H,M,x,k,D,C,O)||this;return P.changesProcessorFactory=t,P.parent=null,P.itemHandler=new Ye(o,k,D,R,y,g,q,C,T,f,i,P),P.collectionHandler=new Ne(R,o,i,F,I,m,M,x,y,P.itemHandler,g,D,q,P),P}return Je(t,e),t.prototype.getServerCache=function(){return this},t.prototype.processResponse=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=this.core.changesDeltaFactory.construct(),o=e.fetchColumnsObject();for(var i in e.items){var s=this.core.columnSetFactory.constructFromResponse(i,o),a=this.core.columnExpansionFactory.construct(i,s.request,o);for(var c in e.items[i])this.itemHandler.processApiResponse(n,e,i,Number(c),s,a)}return this.applyChangesDelta(n,t,r)},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;for(var o in void 0===t&&(t=!1),void 0===r&&(r=!1),e.updated)this.itemHandler.processItemEntryChanges(e.updated[o],r);for(var i in e.deleted)for(var s=0,a=e.deleted[i];s<a.length;s++){var c=a[s];this.itemHandler.entries.clear(c),delete this.itemHandler.itemChanges[c.id]}new ye(this.apiRequestService,this.queryMatcherFactory,this,function(e){return n.collectionHandler.entries.getByItemType(e)}).processDelta(e).removeFromAndAddToCollections(r);for(var u=0,l=this.children;u<l.length;u++){l[u].applyChangesFromParent(e,t,r)}},t.prototype.getLinkFieldsByParent=function(e,t){var r=this.linkTreeService.get()[e.itemType][t],n={};if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");return r.type===k.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},t.prototype.getParent=function(e,t,r){return this.getParentFromFields(e,this.itemHandler.itemChanges[e.id])},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);if(void 0!==r&&void 0!==n)return t?this.apiFormatter.copyFields(r,{},n.columns.main):r;if(void 0===n)throw new Error("No local entry found");throw new Error("No local fields found for ItemEntry with ItemType '"+n.itemType+"'")},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getCollectionChangesRecursively=function(e){var t=this.getLocalCollectionEntry(e),r=this.collectionHandler.collectionChanges[e];if(void 0!==t)return void 0===r&&(r=this.collectionHandler.collectionChanges[e]=[]),r.slice();throw new Error("No local collection items found")},t.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.collectionHandler.entries.forEach(function(e){return e.queueReload()})},t.prototype.applyChangesFromChild=function(e,t,r){return this.changesProcessorFactory.construct(e,t,r).execute()},t.prototype.applyChangesDelta=function(t,r,n){var o=this;return void 0===r&&(r=!0),void 0===n&&(n=!1),0!==t.created.length||s(t.updated)||s(t.deleted)?this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var i=e.prototype._applyChangesDelta.call(o,t),s=i.result,a=i.internalChangesDelta,c=i.rollbackFunctions;for(var u in t.deleted)for(var l=function(e){o.itemHandler.entries.clear(e);var r=o.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete o.itemHandler.itemChanges[e.id],a.setItemDeleted(e),c.push(function(t){t.setItemUpdated(e,r)})},h=0,p=t.deleted[u];h<p.length;h++){l(p[h])}new ye(o.apiRequestService,o.queryMatcherFactory,o,function(e){return o.collectionHandler.entries.getByItemType(e)}).processDelta(a).removeFromAndAddToCollections(n);for(var d=0,f=o.children;d<f.length;d++){f[d].applyChangesFromParent(a,r,n)}return s}):this.promiseService.when({created:[],rollback:Nt})},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);if(void 0!==t)return t},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);if(void 0!==r)return r},t.prototype.getLocalCollectionEntry=function(e){var t=this.collectionHandler.entries.getByEntryId(e);if(void 0!==t)return t},t.prototype.getChangesFromItemChanges=function(e){return e},t}(he),ze=function(){function e(e,t){this.queryMatcherFactory=e,this.transaction=t,this.entries={},this.entriesByEntryId={}}return e.prototype.getByEntryId=function(e){return this.entriesByEntryId[e]},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];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],a=this.transaction.getParent(s);null!==a&&(a.itemType===e&&a.itemId==t&&o.push(s))}return o},e.prototype.batchGetLocalByParent=function(e,t,r,n){for(var o=this.entries[r],i={},s=0,a=t;s<a.length;s++){i[a[s]]=[]}if(void 0===o)return i;for(var c in o){var u=o[c],l=this.transaction.getParent(u);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]={}),this.entriesByEntryId[e.id]=e,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):this.clearByItemId(e.itemType,e.itemId)},e.prototype.clearByItemId=function(e,t){var r=this.entries[e];return void 0!==r&&delete r[t]},e.prototype.matchQuery=function(e,t){var r=this.transaction.getLocalItemEntryChangesTuple(e.id);return!0===this.queryMatcherFactory.construct(e.itemType,this.transaction instanceof Ke?r.changes:r.changes.changes,this.transaction.getParent(e)).matchQuery(t.object)},e}(),Xe=function(){function e(e,t,r){this.authInterface=e,this.keyService=t,this.linkTreeService=r}return e.prototype.matchParent=function(e,t){return null===e&&null===t||!(null===e&&null!==t||null!==e&&null===t)&&(e.itemType===t.itemType&&e.itemId==t.itemId)},e.prototype.getLinkFieldsByParent=function(e,t){var r=this.linkTreeService.get()[e.itemType][t];if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");var n={};return r.type===k.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},e.prototype.getParentByFields=function(e,t,r){var n=this.linkTreeService.get()[e][t.itemType];if(void 0===n)throw new Error("Non existing link between '"+e+"'->'"+t.itemType+"'");var o={};return n.type===k.DIRECT?(o.itemType=e,o.itemId=r[n.field]):(o.itemType=r.itemtype,o.itemId=r.item),o},e.prototype.getDisplayName=function(e,t){switch(e.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:this.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return this.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);default:return t[this.getTitleField(e.itemType)]}},e.prototype.processOptions=function(e){return new L(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.createExistingLocalItemError=function(e){return{message:"A local item of type "+e+" not be created, the ID is already in use"}},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 a=0,c=s;a<c.length;a++){var u=c[a];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.getFullName=function(e,t,r){return void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),e.trim().concat(" ",t).trim().concat(" ",r).trim()},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}(),Ge=function(){function e(){this.separator=":"}return e.prototype.getSingleKey=function(e,t){return e+this.separator+t},e.prototype.getCssKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.join("_")},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}(),Ze=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.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){var t=this.lockItems;for(var r in t)for(var n in t[r]){var o=t[r][n];if(!o.isForeign&&o.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,r=this.errorHandler;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},r.reject).then(function(e){return e.isForeign?r.reject(e.message):e.token},r.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=this.lockItems[e.itemType];return void 0!==t&&delete t[e.itemId]},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}(),$e={},et=function(){function e(e){this.transaction=e,this.parentMap={},this.destination={}}return e.prototype.process=function(){if(void 0===this.transaction.rootItem)throw new Error("A TransactionCache rootItem is required for ModuleChangesCompilation");return this.parentMap=this.createParentMap(),this.processItems(this.transaction.rootItem.itemType,[this.transaction.rootItem],{}),{itemType:this.transaction.rootItem.itemType,itemId:this.transaction.rootItem.itemId,items:this.destination}},e.prototype.createParentMap=function(){var e=this,t={};return this.transaction.itemHandler.entries.forEach(function(r){var n=r.itemType,o=e.transaction.getParent(r);if(null!==o){var i=o.itemType,s=o.itemId;void 0===t[i]&&(t[i]={}),void 0===t[i][s]&&(t[i][s]={}),void 0===t[i][s][n]&&(t[i][s][n]=[]),t[i][s][n].push(r)}}),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.transaction.collectionHandler.entries.getCollectionsByParent(t,r),i=this.transaction.itemHandler.formatRequest(e),a={};for(var c in n)this.processItems(c,n[c],a);for(var u=0,l=o;u<l.length;u++){var h=l[u];null===h.options.query&&this.processItems(h.itemType,this.transaction.collectionHandler.collectionChanges[h.id],a)}var p=s(i),d=s(a);return p&&d?{values:i,links:a}:p?{values:i}:d?{links:a}:$e},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),tt="maybe",rt=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 tt;if(void 0!==e.custom)return tt;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.query)return tt;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 tt;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===tt?tt: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],a=this.matchQuery(s);if(a===r)return e.not?!r:r;a===tt&&(t=tt)}return t===tt?tt:e.not?!t: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),tt;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":var i=c(e,o);return t.not?!i:i;default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}(),nt=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){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(Le||(Le={}));var ot=Object.keys(Ee).map(function(e){return Ee[e]}),it=((je={})[Ee.EQUALS]=Ee.NOT_EQUALS,je[Ee.NOT_EQUALS]=Ee.EQUALS,je[Ee.MORE_THAN]=Ee.LESS_OR_EQUAL_THAN,je[Ee.LESS_THAN]=Ee.EQUAL_OR_MORE_THAN,je[Ee.LESS_OR_EQUAL_THAN]=Ee.MORE_THAN,je[Ee.EQUAL_OR_MORE_THAN]=Ee.LESS_THAN,je[Ee.IN]=Ee.IN,je),st=function(e){function t(t,r){var n=e.call(this,t)||this;return n.parameters=r,n}return nt(t,e),t.prototype.parseEmptyQuery=function(){return[{},"{}"]},t.prototype.parseSubQuery=function(e,t,r){void 0===r&&(r=!1);var n=this.parse(t);return[{key:e,query:n[Le.OBJ],not:r},"[sub"+Le.SEP+e+Le.SEP+n[Le.STR]+Le.SEP+r+"]"]},t.prototype.parseSubFieldQuery=function(e,t,r,n,o){void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),void 0===o&&(o=!1);var i=this.parse(n);return[{key:e,itemType:t,field:r,query:i[Le.OBJ],not:o},"[subField"+Le.SEP+e+Le.SEP+t+Le.SEP+r+Le.SEP+i[Le.STR]+Le.SEP+o+"]"]},t.prototype.parseSearchQuery=function(e,t){return void 0===t&&(t=!1),[{search:(e=this.formatValue(e))[Le.OBJ],not:t},"[search"+Le.SEP+e[Le.STR]+Le.SEP+t+"]"]},t.prototype.parseCustomQuery=function(e,t,r){if(void 0===r&&(r=!1),void 0===t)return[{custom:e,not:r},"["+e+Le.SEP+r+"]"];var n=this.parseCustomParameters(t);return[{custom:e,parameters:n[Le.OBJ],not:r},"["+e+Le.SEP+n[Le.STR]+Le.SEP+r+"]"]},t.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[Le.OBJ],o>0&&(n+=Le.SEP),n+=s[Le.STR]}return[r,n]},t.prototype.parseSimpleQuery=function(e,t,r,n){if(void 0===n&&(n=!1),t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[Le.OBJ])?Ee.IN:Ee.EQUALS),-1===ot.indexOf(r))throw new Error("Unknown comparator '"+r+"', it might be that the backend supports it but the frontend doesn't !");n&&(r=it[r]);var o=r===Ee.IN&&n,i=[{key:e,value:t[Le.OBJ],comparator:r,not:o},"["+r+Le.SEP+e+Le.SEP+t[Le.STR]+"]"];return o&&(i[1]=i[1].slice(0,-1),i[1]+=Le.SEP+n+"]"),i},t.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[Le.OBJ],reverse:r,not:n},"[linkedTo"+Le.SEP+e+Le.SEP+o[Le.STR]+Le.SEP+r+Le.SEP+n+"]"]},t.prototype.parseComplexQuery=function(e,t,r){void 0===t&&(t=Fe.AND),void 0===r&&(r=!1),t=t.toUpperCase();var n=this.parseConditions(e);return[{conditions:n[Le.OBJ],operator:t,not:r},"["+t+n[Le.STR]+Le.SEP+r+"]"]},t.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],o="",i=0,s=e;i<s.length;i++){var a=s[i];r.push(this.parse(a))}for(var c=0,u=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});c<u.length;c++){var l=u[c];n.push(l[Le.OBJ]),o+=l[Le.STR]}return[n,o]},t.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]},t.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():n.isMoment(e)?n(e):n.isDuration(e)?n.duration(e):e},t.prototype.compareParsedQueries=function(e,t){return e[Le.STR]===t[Le.STR]?0:e[Le.STR]>t[Le.STR]?1:-1},t}(Ae),at=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||e.operator===Fe.OR?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return e.operator===Fe.OR?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:Fe.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:Ee.IN,key:"id",value:e,not:!0}},e}(),ct=function(){function e(e){this.columnUtil=e,this.columns={},this.columnSetIdMap={}}return e.prototype.expandWithRequestColumns=function(e,t){var r=this.columns;void 0===r[e]&&(r[e]=[]),r[e]=this.columnUtil.mergeRequestColumns(r[e],t).merged},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}(),ut=function(){function e(e,t,r,n,o,i,s,a){this.requestBufferManager=e,this.changesDeltaFactory=t,this.apiFormatter=r,this.errorHandler=n,this.transactionCacheFactory=o,this.promiseService=i,this.requestColumnExpansionFactory=s,this.apiRequestService=a}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)}},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=this.transactionCacheFactory.getServerCache(),o={};for(var i in t){var s=t[i],a=null!==s.parent?s.parent:{},c=this.formatMessageValues(s.values,r);o[i]=n.collectionHandler.entries.getByFittingItem(e,c,a)}return o},e.prototype.getRequestColumns=function(e,t){var r=this.transactionCacheFactory.getServerCache(),n=this.requestColumnExpansionFactory.construct();for(var o in t){for(var i=t[o].fitting,s=r.itemHandler.entries.get(e,o),a=0,c=i;a<c.length;a++){var u=c[a];n.expand(u.columns)}void 0!==s&&n.expand(s.columns)}return n.get()},e.prototype.processMessage=function(e){var t=this.transactionCacheFactory.getServerCache(),r=e.itemType,n=[],o=this.createCollectionMap(r,e.items[r],e.columns[r]),i=this.getRequestColumns(r,o);for(var s in o){var a=+s;void 0===t.itemHandler.entries.get(r,s)?0!==o[a].fitting.length&&n.push(a):n.push(a)}return 0===n.length?this.promiseService.when():this.apiRequestService.query(r,{key:"id",comparator:"IN",value:n},i).then(function(e){t.processResponse(e,!1,!0)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=this.transactionCacheFactory.getServerCache(),n=e.items.FunctionChangesResolve,o=[];for(var i in n){var s=n[i].parent.itemId,a=r.itemHandler.entries.get("Functie",s);void 0!==a&&void 0!==a.columns.response.Functie.newchanges&&o.push(s)}return 0===o.length?this.promiseService.when():this.requestBufferManager.fetchByIds("Functie",o,["newchanges"]).then(function(e){for(var n=t.changesDeltaFactory.construct(),o=0,i=e.response.links.Functie;o<i.length;o++){var s=i[o],a=r.itemHandler.entries.get("Functie",s),c=r.itemHandler.itemChanges[a.id],u=e.response.fetchObject("Functie",s,!1);void 0!==u&&u.newchanges!==c.newchanges&&n.setItemUpdated(a,{newchanges:u.newchanges})}return r.applyChangesDelta(n,!1,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.isFunctionChangesResolveMessage=function(e){return"FunctionChangesResolve"===e.body.itemType},e.prototype.handleCreate=function(e){var t=e.body;return this.isFunctionChangesResolveMessage(e)?this.processFunctionChangesResolve(t):this.processMessage(t).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=this.changesDeltaFactory.constructInternalDelta(),r=this.transactionCacheFactory.getServerCache(),n=e.body,o=[],i=0,s=n.items;i<s.length;i++){var a=s[i],c=r.itemHandler.entries.get(n.itemType,a);void 0!==c&&o.push(c)}return t.setItemsDeleted(o),r.applyChangesFromParent(t,!1,!0),this.promiseService.when()},e.prototype.handleLinkMove=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e}(),lt=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)}}(),ht=function(){return(ht=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},pt=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m){var y=e.call(this,a,r,t,s,m)||this;return y.columnSubsetCacheFactory=n,y.columnExpansionFactory=o,y.changesDeltaFactory=i,y.collectionMatcherFactory=c,y.columnHandler=u,y.errorHandler=l,y.itemHandler=h,y.keyService=p,y.promiseService=d,y.exceptionHandler=f,y.transaction=m,y.collectionResources={},y}return lt(t,e),t.prototype.getAllCollectionsByItemType=function(e){var t=[];for(var r in this.collectionChanges){var n=this.transaction.getLocalCollectionEntry(Number(r));void 0!==n&&n.itemType===e&&t.push(n)}return t},t.prototype.createCollectionEntry=function(t,r){return this.isLocal(r)?e.prototype.createCollectionEntry.call(this,t,r):this.transaction.getServerCache().collectionHandler.createCollectionEntry(t,r)},t.prototype.onItemEntriesCreated=function(e,t){var r=this.collectionResources[e.id];if(void 0!==r)for(var n=0,o=r;n<o.length;n++){var i=o[n];try{i.options.onItemsCreated(t)}catch(e){this.exceptionHandler(e)}}},t.prototype.clearEntry=function(e){this.entries.clear(e),delete this.collectionResources[e.id],delete this.collectionChanges[e.id]},t.prototype.addResource=function(e){var t=this.collectionResources[e.entry.id];void 0===t&&(t=this.collectionResources[e.entry.id]=[]),t.push(e)},t.prototype.clearResource=function(e){var t=this.collectionResources[e.entry.id],r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&delete this.collectionResources[e.entry.id]},t.prototype.moveItems=function(e,t,r){if(e.itemType!==t.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var n=this.changesDeltaFactory.construct(),o=0,i=r;o<i.length;o++){var s=i[o];n.setItemMoved(s,t.parent)}this.transaction.applyChangesDelta(n)},t.prototype.extendCollectionEntry=function(e,t){return this.transaction.getServerCache().collectionHandler.extendCollectionEntry(e,t)},t.prototype.cloneCollectionEntry=function(e,t,r){void 0===r&&(r={});var n=this.collectionChanges[e.id],o=this.createCollectionEntry(e.itemType,this.collectionEntryService.cloneOptions(e.options,t));if(null!==e.parent){var i=e.parent;void 0===r[i.itemType]&&(r[i.itemType]={}),r[i.itemType][i.itemId]=t.itemId}return this.itemHandler.cloneItemEntries(n,r),o},t.prototype.getCollectionMatcher=function(){var e=this;return this.collectionMatcherFactory.construct(this.transaction,function(t){return e.getAllCollectionsByItemType(t)})},t.prototype.fetchCollectionEntry=function(e,t){var r=this;if(!this.isLocal(t))return this.transaction.getServerCache().collectionHandler.fetchCollectionEntry(e,t);var n,o=this.changesDeltaFactory.construct(),i=this.columnSubsetCacheFactory.construct(t.columns),s=this.collectionEntryService.createQuery(t);return this.expandColumnsWithQueryColumns(e,t,s.object),this.fetchCollectionData(o,e,i,t,s).then(function(e){return n=e,r.transaction.applyChangesDelta(o)},this.errorHandler.reject).then(function(){return n},this.errorHandler.reject)},t.prototype.fetchLinkedCollectionEntries=function(e,t,r,n){S(t)&&(t=t());for(var o=[],i=[],s=0,a=t;s<a.length;s++){var c=a[s];this.keyService.isLocalId(c)?i.push(c):o.push(c)}return this.promiseService.all({remote:this.transaction.getServerCache().collectionHandler.fetchLinkedCollectionEntries(e,o,r,n),local:this.fetchLinkedLocalCollectionEntries(e,i,r,n)}).then(function(e){return ht({},e.remote,e.local)})},t.prototype.expandCollectionEntries=function(e,t,r,n){return this.transaction.getServerCache().collectionHandler.expandCollectionEntries(e,t,r,n)},t.prototype.extendCollectionEntries=function(e,t,r,n,o){return this.transaction.getServerCache().collectionHandler.extendCollectionEntries(e,t,r,n,o)},t.prototype.addItemEntriesToCollectionChanges=function(t,r,n){void 0===n&&(n=!1),e.prototype._addItemEntriesToCollectionChanges.call(this,t,r,function(){return!1},n)},t.prototype.isLocal=function(e){var t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)},t.prototype.expandCollectionEntry=function(e,t,r){var n=this,o=t.columns.mergeRequestColumns(r).difference;if(!0!==o&&0===o.length)return this.promiseService.when(t);var i=t.itemType;return this.columnHandler.fetch(i,o).then(function(r){return n.itemHandler.expandLocalItemEntries(e,i,n.collectionChanges[t.id],o,r).then(function(){var e=n.columnExpansionFactory.construct(i,o,r);return t.expandColumns(e),t},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.handleAddedItemEntriesCallback=function(e,t){var r=this.collectionResources[e.id];if(0!==t.length&&void 0!==r&&0!==r.length)for(var n=0,o=r;n<o.length;n++){o[n].addItemResources(t)}},t.prototype.handleRemovedItemEntriesCallback=function(e,t){var r=this.collectionResources[e.id];if(0!==t.length&&void 0!==r&&0!==r.length)for(var n=0,o=r;n<o.length;n++){var i=o[n],s=i.removeItemResources(t);i.callOnRemove(s)}},t.prototype.fetchCollectionData=function(e,t,r,n,o){var i=this.entries.getByQuery(t,o);return null!==i?r.run(i.columns)?this.promiseService.when(i):this.expandCollectionEntry(e,i,r.requestColumns):this.promiseService.when(this.createCollectionEntry(t,n))},t.prototype.fetchLinkedLocalCollectionEntries=function(e,t,r,n){for(var o=this,i=this.changesDeltaFactory.construct(),s=this.columnSubsetCacheFactory.construct(n.columns),a={},c=0,u=t;c<u.length;c++){var l=u[c],h=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:l}),p=this.collectionEntryService.createQuery(h);this.expandColumnsWithQueryColumns(r,h,p.object),a[l]=this.fetchCollectionData(i,r,s,h,p)}return this.promiseService.all(a).then(function(e){return o.transaction.applyChangesDelta(i).then(function(){return e},o.errorHandler.reject)},this.errorHandler.reject)},t}(Ue),dt=function(){function e(e){this.itemEntryService=e,this.updated={},this.deleted={}}return e.prototype.setItemUpdated=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),void 0===this.updated[e.id]&&(this.updated[e.id]={entry:e,changes:{fields:{},expandedColumns:null,parent:n}});var o=this.updated[e.id];if(null!==n){var i=this.itemEntryService.getLinkFieldsByParent(n,e.itemType);for(var s in i)t[s]=i[s]}for(var a in t){var c=Object.getOwnPropertyDescriptor(t,a);void 0!==c?Object.defineProperty(o.changes.fields,a,c):o.changes.fields[a]=t[a]}null!==r&&(o.changes.expandedColumns=r)},e.prototype.setItemDeleted=function(e){this.setItemsDeleted([e])},e.prototype.setItemsDeleted=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];void 0===this.deleted[n.itemType]&&(this.deleted[n.itemType]=[]),this.deleted[n.itemType].indexOf(n)>-1||this.deleted[n.itemType].push(n)}},e}(),ft=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)}}(),mt=function(e){function t(t){var r=e.call(this,t)||this;return r.created=[],r}return ft(t,e),t.prototype.setItemCreated=function(e,t,r,n){void 0===n&&(n=null);var o={};if(null!==n)for(var i in o=this.itemEntryService.getLinkFieldsByParent(n,r.itemType))t[i]=o[i];var s=this.itemEntryService.getLocalDefaultValues();for(var i in s)t[i]=s[i];this.created.push({itemId:e,fields:t,columns:r})},t.prototype.setItemMoved=function(e,t){this.setItemUpdated(e,{},null,t)},t}(dt),yt=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)}}(),vt=function(e){function t(t){var r=e.call(this,t)||this;return r.created={},r.moved={},r.itemIdConversionMap={},r}return yt(t,e),t.prototype.setItemCreated=function(e,t){this.created[e.id]={entry:e,fields:t}},t.prototype.setItemMoved=function(e,t){this.moved[e.id]={entry:e,to:t}},t}(dt),gt=function(){function e(e,t,r,n,o){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.serverCache=n,this.itemType=o,this.deferred=this.promiseLibrary.defer(),this.requestColumnExpansion=this.requestColumnExpansionFactory.construct(),this.singleItemIds=[],this.queries={}}return e.prototype.containsId=function(e){return-1!==this.singleItemIds.indexOf(e)},e.prototype.containsQuery=function(e){return void 0!==this.queries[e]},e.prototype.addSingleItem=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),-1===this.singleItemIds.indexOf(e)&&this.singleItemIds.push(e),this.getPromise()},e.prototype.addQuery=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),void 0===this.queries[e[1]]&&(this.queries[e[1]]=e[0]),this.getPromise()},e.prototype.flush=function(){var e=this,t=[];for(var r in this.singleItemIds.length>0&&t.push({key:"id",comparator:"IN",value:this.singleItemIds}),this.queries)t.push(this.queries[r]);if(0===t.length)throw new Error("Tried to flush a RequestBuffer without singleItems or queries");var n=this.requestColumnExpansion.get();return this.apiRequestService.query(this.itemType,{conditions:t,operator:"OR"},n).then(function(t){e.serverCache.processResponse(t,!1,!1),e.deferred.resolve(t)},function(t){e.deferred.reject(t)}),this.getPromise()},e.prototype.getPromise=function(){return this.deferred.promise},e}(),Ct=function(){function e(e,t,r,n,o){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.keyService=n,this.errorHandler=o,this.pendingBufferMap={},this.pendingTrueBufferMap={},this.pendingQueryBufferMap={},this.pendingTemplateBufferMap={}}return e.prototype.setServerCache=function(e){this.serverCache=e},e.prototype.containsId=function(e,t){return!!d(this.pendingTemplateBufferMap,[e,t])||void 0!==this.pendingBufferMap[e]&&this.pendingBufferMap[e].containsId(t)},e.prototype.containsQuery=function(e,t){return void 0!==d(this.pendingQueryBufferMap,[e,t])},e.prototype.fetchByIds=function(e,t,r){for(var n=0,o=t;n<o.length;n++){var i=o[n];this.fetchById(e,i,r)}return this.pendingBufferMap[e].getPromise()},e.prototype.fetchById=function(e,t,r){if(this.keyService.isLocalId(t))throw new Error("Unexpected local ItemId in RequestBufferManager.fetchById, for local ItemIds you should use RequestBufferManager.fetchByLocalId");var n;return!0===r?void 0===(n=this.pendingTrueBufferMap[e])?n=this.constructBuffer(e,this.pendingTrueBufferMap):console.log("Existing 'columns: true' RequestBuffer "+e+" at "+performance.now()+" by id"):void 0===(n=this.pendingBufferMap[e])?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" by id"),n.addSingleItem(t,r),n.getPromise()},e.prototype.fetchByQuery=function(e,t,r){var n=this.pendingBufferMap[e];return void 0===n?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" with query"),n.addQuery(t,r),n.getPromise()},e.prototype.fetchByLocalId=function(e,t,r){return void 0===t&&(t="no-id"),void 0===this.pendingTemplateBufferMap[e]||void 0===this.pendingTemplateBufferMap[e][t]?this.constructTemplateBuffer(e,t,r):this.pendingTemplateBufferMap[e][t]},e.prototype.constructBuffer=function(e,t){void 0===t&&(t=this.pendingBufferMap);var r=t[e]=new gt(this.promiseLibrary,this.apiRequestService,this.requestColumnExpansionFactory,this.serverCache,e);return window.setTimeout(function(){r.flush(),delete t[e]},150),r},e.prototype.constructTemplateBuffer=function(e,t,r){var n=this;return void 0===this.pendingTemplateBufferMap[e]&&(this.pendingTemplateBufferMap[e]={}),this.pendingTemplateBufferMap[e][t]=this.apiRequestService.template(e,r).then(function(r){return delete n.pendingTemplateBufferMap[e][t],r},function(){return delete n.pendingTemplateBufferMap[e][t],n.errorHandler.reject()})},e}(),It=function(){function e(e,t,r,n,o,i,s){this.columnUtil=e,this.promiseService=t,this.requestBufferFactory=r,this.columnHandler=n,this.templateFactory=o,this.errorHandler=i,this.requestColumnExpansionFactory=s,this.templates={}}return e.prototype.fetchTemplate=function(e,t,r,n,o){var i=this;void 0===r&&(r={}),void 0===n&&(n={}),void 0===o&&(o=null);var a=s(r),c=this.requestColumnExpansionFactory.construct();if(void 0!==n[e]&&c.expandWithRequestColumns(e,n[e]),c.expandWithRequestColumns(e,[{creator:["displayname"]},"created","permissions"]),null!==o&&c.expandWithRequestColumns(e,this.columnUtil.getColumnsFromLink("string"==typeof o?o:o.itemType,e)),n[e]=c.get()[e],!a){var u=this.templates[e];if(void 0!==u&&(null===e||this.columnUtil.responseColumnsAvailable(e,n[e],u.responseColumns)))return this.promiseService.when(u)}return this.promiseService.all({template:this.requestBufferFactory.fetchByLocalId(e,t,r),additionalColumns:void 0===n[e]?{}:this.columnHandler.fetch(e,n[e])}).then(function(t){var r=t.template,o=i.templateFactory.construct(e,r,n,t.additionalColumns);return!a&&r.cacheable&&(i.templates[e]=o),o},this.errorHandler.reject)},e}(),Ft=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new P(this.apiFormatter,e)},e}(),Et=function(){function e(){}return e.prototype.construct=function(e){return new _(e)},e}(),St=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e){return new Se(this.queryMatcherFactory,e)},e}(),Rt=function(){function e(e,t,r){this.collectionEntryService=e,this.columnSetFactory=t,this.keyService=r}return e.prototype.construct=function(e,t){return new X(this.collectionEntryService,this.columnSetFactory,this.keyService,e,new J(t))},e}(),qt=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e,t){return new fe(this.queryMatcherFactory,e,t)},e}(),Tt=function(){function e(e,t,r,n,o,i){this.errorHandler=e,this.exceptionHandler=t,this.itemResourceFactory=r,this.keyService=n,this.promiseService=o,this.changesDeltaFactory=i}return e.prototype.construct=function(e,t,r){var n=new K(t);return n.editCollection?new te(this,e,n,r):new $(this,e,n,r)},e}(),wt=function(){function e(e){this.columnInfoFactory=e}return e.prototype.construct=function(e,t,r){return new we(this.columnInfoFactory,e,t,r)},e}(),bt=function(){function e(){}return e.prototype.construct=function(e,t){return new Me(e,t)},e.prototype.constructFromRootMap=function(e,t){void 0===t&&(t=null);var r=[];for(var n in e){var o=e[n],i=this.construct(o.apiColumn,t),s=this.constructFromRootMap(o.children,i);s.length>0&&i.setChildren(i.apiColumn.itemType,s),r.push(i)}return r},e}(),Ht=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){var r=new De(this.columnUtil,this,e);return r.request=t,r.requestColumnsTrue=!0===t,r},e.prototype.resolveStub=function(e,t,r,n){return void 0===r&&(r=!0),void 0===n&&(n=!0),e.requestColumnsTrue?this.processResponseColumns(e,t,r):this.processRequestColumns(e,t,r,n)},e.prototype.construct=function(e,t,r,n,o){return this.resolveStub(this.constructStub(e,t),r,n,o)},e.prototype.constructFromResponse=function(e,t,r){void 0===r&&(r=!0);var n=new De(this.columnUtil,this,e);return n.requestColumnsTrue=!1,this.processResponseColumns(n,t,r)},e.prototype.processResponseColumns=function(e,t,r){var n=e.itemType,o={};return e.response=t,this.expandRootColumnMapFromResponseColumns(n,t,o,r,{}),this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(o),n),e.request=this.constructRequestColumnsFromRootColumnMap(o),e},e.prototype.constructRequestColumnsFromRootColumnMap=function(e){var t,r=[];for(var n in e){var o=e[n];s(o.children)?r.push(((t={})[n]=this.constructRequestColumnsFromRootColumnMap(o.children),t)):r.push(n)}return r},e.prototype.expandRootColumnMapFromResponseColumns=function(e,t,r,n,o){if(!0!==o[e])for(var i in o[e]=!0,t[e]){var a=t[e][i];if(void 0!==a&&(n&&this.columnHandler.setColumn(e,a),void 0===r[i]&&(r[i]={apiColumn:a,children:{}}),this.columnUtil.isItemColumn(a,!1))){var c=t[a.itemType];void 0!==c&&s(c)&&this.expandRootColumnMapFromResponseColumns(a.itemType,t,r[i].children,n,o)}}},e.prototype.processRequestColumns=function(e,t,r,n){var o=e.itemType,i={};return this.expandRootColumnMap(e.request,o,t,i,r),n&&this.expandRootColumnMap(["id"],o,t,i,r),e.response={},this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(i),o),e},e.prototype.processColumnInfo=function(e,t,r){var n=e.response;void 0===n[r]&&(n[r]={});for(var o=0,i=t;o<i.length;o++){var s=i[o];n[r][s.id]=s.apiColumn,e.groupColumnInfo(s),s.isLeaf||this.processColumnInfo(e,s.children,s.itemType)}},e.prototype.expandRootColumnMap=function(e,t,r,n,o){for(var i=0,s=e;i<s.length;i++){var a=s[i],c=this.columnUtil.parseRequestColumn(a),u=c.id,l=c.children,h=void 0;void 0!==r[t]&&(h=r[t][u]),void 0!==h?(o&&(h=this.columnHandler.setColumn(t,h)),void 0===n[u]&&(n[u]={apiColumn:h,children:{}}),0!==l.length&&this.expandRootColumnMap(l,h.itemType,r,n[u].children,o)):console.warn("No api column for request column",u,"for itemType",t)}},e}(),Mt=function(){function e(){}return e.prototype.construct=function(e){return new Oe(e)},e}(),xt=function(){function e(e,t,r){this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r}return e.prototype.construct=function(e,t,r){return new _e(this.apiFormatter,this.keyService,this.requestColumnExpansionFactory,e,t,r)},e}(),kt=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e){return new ze(this.queryMatcherFactory,e)},e}(),Dt=function(){function e(e,t,r,n,o,i,s,a){this.authInterface=e,this.apiFormatter=t,this.columnSetFactory=r,this.exceptionHandler=n,this.itemEntryService=o,this.itemResourceFactory=i,this.keyService=s,this.promiseService=a}return e.prototype.construct=function(e,t){return new Q(this,t.itemType,e,t)},e}(),Ot=function(){function e(e,t,r,n,o,i,s){this.apiFormatter=e,this.lockService=t,this.errorHandler=r,this.promiseService=n,this.exceptionHandler=o,this.columnUtil=i,this.linkTreeService=s}return e.prototype.getConstructor=function(e,t){var r=this,n=new A(e);return function(e){return r.constructWithOptions(e,n,t)}},e.prototype.construct=function(e,t,r,n){return this.constructWithOptions(e,new A(t),r,n)},e.prototype.constructWithOptions=function(e,t,r,n){return void 0===n&&(n=!1),t.edit?new Y(this,e,t,n,r):t.remote?new oe(this,e,t,n,r):new se(this,e,t,n,r)},e}(),Pt=function(){function e(e,t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D){this.core=e,this.columnCache=t,this.requestBufferManager=r,this.requestColumnExpansionFactory=n,this.queryMatcherFactory=o,this.authInterface=i,this.changesDeltaFactory=s,this.changesProcessorFactory=a,this.lockService=c,this.moduleChangesCompilationFactory=u,this.collectionResourceFactory=l,this.itemResourceFactory=h,this.templateCache=p,this.itemCacheFactory=d,this.collectionCacheFactory=f,this.errorHandler=m,this.exceptionHandler=y,this.promiseService=v,this.apiFormatter=g,this.apiRequestService=C,this.columnExpansionFactory=I,this.columnHandler=F,this.columnSetFactory=E,this.columnSubsetCacheFactory=S,this.columnUtil=R,this.itemEntryFactory=q,this.itemEntryService=T,this.keyService=w,this.collectionEntryFactory=b,this.collectionEntryService=H,this.collectionMatcherFactory=M,this.queryParserFactory=x,this.queryService=k,this.linkTreeService=D,this.serverCache=new Ke(this.changesProcessorFactory,this.core,this.columnCache,this.requestBufferManager,this.requestColumnExpansionFactory,this.queryMatcherFactory,this.authInterface,this.changesDeltaFactory,this.lockService,this.moduleChangesCompilationFactory,this.collectionResourceFactory,this.itemResourceFactory,this.templateCache,this.itemCacheFactory,this.collectionCacheFactory,this.errorHandler,this.exceptionHandler,this.promiseService,this.apiFormatter,this.apiRequestService,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnSubsetCacheFactory,this.columnUtil,this.itemEntryFactory,this.itemEntryService,this.keyService,this.collectionEntryFactory,this.collectionEntryService,this.collectionMatcherFactory,this.queryParserFactory,this.queryService,this.linkTreeService)}return e.prototype.getById=function(e){var t=function(r){for(var n=0,o=r;n<o.length;n++){var i=o[n];if(i.id===e)return i;var s=t(i.children);if(void 0!==s)return s}};return t(this.serverCache.children)},e.prototype.construct=function(e){return this.serverCache.createChild(e)},e.prototype.getServerCache=function(){return this.serverCache},e}(),_t=function(){function e(){}return e.prototype.construct=function(e){return new et(e)},e}(),jt=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new rt(this.apiFormatter,e,t,r)},e}(),Lt=function(){function e(){}return e.prototype.construct=function(e,t){return new st(e,t)},e}(),At=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new ct(this.columnUtil)},e}(),Bt=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r,n){return new re(this,e,t,r,n)},e}(),Qt=function(){function e(e){this.itemEntryService=e}return e.prototype.construct=function(){return new mt(this.itemEntryService)},e.prototype.constructInternalDelta=function(){return new vt(this.itemEntryService)},e}(),Ut=function(){function e(e,t,r,n,o,i,s,a,c,u){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=o,this.errorHandler=i,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u}return e.prototype.construct=function(e,t,r){return new j(this.changesDeltaFactory,this.apiRequestService,this.changesCompilationFactory,this.columnExpansionFactory,this.createRequestFactory,this.errorHandler,this.promiseService,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,e,t,r)},e}(),Vt=function(){return function(e,t,r,n,o,i){this.version="2.0.11",this.noop=Nt;var s=new Ge,a=new Xe(t,s,i),c=new Qt(a),u=new D,l=new Ft(u),h=new O(e,l),p=new jt(u),d=new Lt,f=new at,m=new Pe(i),y=new Te(m),v=new be(h,r,o,y,m),g=new bt,C=new wt(g),I=new Ht(v,m,g),F=new Mt,E=new Ze(h,r,s,o),S=new Bt(I,m),R=new kt(p),q=new Ot(u,E,r,o,n,m,i),T=new Tt(r,n,q,s,o,c),w=new Dt(t,u,I,n,a,q,s,o),b=new Re(d,f),H=new qe,M=new Rt(b,I,s),x=new St(p),k=new qt(p),P=new At(m),_=new xt(u,s,P),j=new Et,L=new Ut(c,h,j,C,_,r,o,P,b,a),A=new _t,B=new Ct(o,h,P,s,r),Q=new It(m,o,B,v,S,r,P),U=new Pt(this,y,B,P,p,t,c,L,E,A,T,q,Q,R,x,r,n,o,u,h,C,v,I,F,m,w,a,s,M,b,k,d,f,i);B.setServerCache(U.getServerCache());var V=new ut(B,c,u,r,U,o,P,h);this.apiFormatter=u,this.apiRequestService=h,this.apiResponseProcessorFactory=l,this.changesCompilationFactory=j,this.changesProcessorFactory=L,this.collectionCacheFactory=x,this.collectionEntryFactory=M,this.collectionEntryService=b,this.collectionMatcherFactory=k,this.collectionResourceFactory=T,this.collectionResourceService=H,this.columnCache=y,this.columnExpansionFactory=C,this.columnHandler=v,this.columnInfoFactory=g,this.columnSetFactory=I,this.columnSubsetCacheFactory=F,this.columnUtil=m,this.createRequestFactory=_,this.itemCacheFactory=R,this.itemEntryFactory=w,this.itemEntryService=a,this.itemResourceFactory=q,this.keyService=s,this.transactionCacheFactory=U,this.lockService=E,this.moduleChangesCompilationFactory=A,this.queryMatcherFactory=p,this.queryParserFactory=d,this.queryService=f,this.requestColumnExpansionFactory=P,this.socketMessageHandler=V,this.templateFactory=S,this.changesDeltaFactory=c,this.templateCache=Q}}();function Nt(){}function Wt(e){return e}r.d(t,"RmCore",function(){return Vt}),r.d(t,"noop",function(){return Nt}),r.d(t,"identity",function(){return Wt}),r.d(t,"ALL_PERMISSIONS",function(){return"7"}),r.d(t,"COLUMN_SEPERATOR",function(){return He}),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,"ItemEntryOptions",function(){return L}),r.d(t,"ItemResourceOptions",function(){return A}),r.d(t,"ItemEntry",function(){return Q}),r.d(t,"ItemResource",function(){return U}),r.d(t,"ViewResource",function(){return N}),r.d(t,"EditResource",function(){return Y}),r.d(t,"CollectionEntryOptions",function(){return J}),r.d(t,"CollectionResourceOptions",function(){return K}),r.d(t,"CollectionEntry",function(){return X}),r.d(t,"CollectionResource",function(){return G}),r.d(t,"CollectionViewResource",function(){return $}),r.d(t,"CollectionEditResource",function(){return te}),r.d(t,"Template",function(){return re}),r.d(t,"RemoteViewResource",function(){return oe}),r.d(t,"LocalViewResource",function(){return se}),r.d(t,"ApiFormatter",function(){return D}),r.d(t,"ApiRequestService",function(){return O}),r.d(t,"ApiResponseProcessor",function(){return P}),r.d(t,"ChangesCompilation",function(){return _}),r.d(t,"ChangesProcessor",function(){return j}),r.d(t,"CollectionCache",function(){return Se}),r.d(t,"CollectionEntryService",function(){return Re}),r.d(t,"CollectionMatcher",function(){return fe}),r.d(t,"CollectionResourceService",function(){return qe}),r.d(t,"ColumnCache",function(){return Te}),r.d(t,"ColumnExpansion",function(){return we}),r.d(t,"ColumnHandler",function(){return be}),r.d(t,"ColumnInfo",function(){return Me}),r.d(t,"ColumnSet",function(){return De}),r.d(t,"ColumnSubsetCache",function(){return Oe}),r.d(t,"ColumnUtil",function(){return Pe}),r.d(t,"CreateRequest",function(){return _e}),r.d(t,"ItemCache",function(){return ze}),r.d(t,"ItemEntryService",function(){return Xe}),r.d(t,"KeyService",function(){return Ge}),r.d(t,"TransactionEventHandler",function(){return ve}),r.d(t,"LockService",function(){return Ze}),r.d(t,"ModuleChangesCompilation",function(){return et}),r.d(t,"QueryMatcher",function(){return rt}),r.d(t,"CONSTANTS",function(){return Le}),r.d(t,"QueryParser",function(){return st}),r.d(t,"QueryService",function(){return at}),r.d(t,"RequestColumnExpansion",function(){return ct}),r.d(t,"SocketMessageHandler",function(){return ut}),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 a}),r.d(t,"inArray",function(){return c}),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 d}),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 F}),r.d(t,"isArray",function(){return E}),r.d(t,"isFunction",function(){return S}),r.d(t,"isRegExp",function(){return R}),r.d(t,"isBoolean",function(){return q}),r.d(t,"isElement",function(){return T}),r.d(t,"isWindow",function(){return w}),r.d(t,"isDefined",function(){return b}),r.d(t,"equals",function(){return H}),r.d(t,"copy",function(){return M}),r.d(t,"AbstractCache",function(){return he}),r.d(t,"ServerCache",function(){return Ke}),r.d(t,"ServerItemHandler",function(){return Ye}),r.d(t,"ServerCollectionHandler",function(){return Ne}),r.d(t,"TransactionCache",function(){return Ie}),r.d(t,"TransactionItemHandler",function(){return le}),r.d(t,"TransactionCollectionHandler",function(){return pt}),r.d(t,"ChangesDelta",function(){return mt}),r.d(t,"InternalChangesDelta",function(){return vt}),r.d(t,"RequestBufferManager",function(){return Ct}),r.d(t,"RequestBuffer",function(){return gt}),r.d(t,"ApiResponseProcessorFactory",function(){return Ft}),r.d(t,"ChangesCompilationFactory",function(){return Et}),r.d(t,"CollectionCacheFactory",function(){return St}),r.d(t,"CollectionEntryFactory",function(){return Rt}),r.d(t,"CollectionMatcherFactory",function(){return qt}),r.d(t,"CollectionResourceFactory",function(){return Tt}),r.d(t,"ColumnExpansionFactory",function(){return wt}),r.d(t,"ColumnInfoFactory",function(){return bt}),r.d(t,"ColumnSetFactory",function(){return Ht}),r.d(t,"ColumnSubsetCacheFactory",function(){return Mt}),r.d(t,"CreateRequestFactory",function(){return xt}),r.d(t,"ItemCacheFactory",function(){return kt}),r.d(t,"ItemEntryFactory",function(){return Dt}),r.d(t,"ItemResourceFactory",function(){return Ot}),r.d(t,"TransactionCacheFactory",function(){return Pt}),r.d(t,"ModuleChangesCompilationFactory",function(){return _t}),r.d(t,"QueryMatcherFactory",function(){return jt}),r.d(t,"QueryParserFactory",function(){return Lt}),r.d(t,"RequestColumnExpansionFactory",function(){return At}),r.d(t,"TemplateFactory",function(){return Bt}),r.d(t,"ChangesDeltaFactory",function(){return Qt}),r.d(t,"ChangesProcessorFactory",function(){return Ut}),r.d(t,"ApiLinkTreeType",function(){return k})}])});
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 a(e){if("object"!=typeof e)return null;for(var t in e)return t;return null}function c(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,a=r;s<a.length;s++){var c=a[s];e.push(c)}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 d(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 f(e,t,r){for(var n=0,o=t.length;n<o;++n){var i=t[n];if(v(i)||S(i))for(var s=Object.keys(i),a=0,c=s.length;a<c;a++){var u=s[a],l=i[u];r&&v(l)?F(l)?e[u]=new Date(l.valueOf()):R(l)?e[u]=new RegExp(l):l.nodeName?e[u]=l.cloneNode(!0):T(l)?e[u]=l.clone():(v(e[u])||(e[u]=E(l)?[]:{}),f(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 f(e,t,!1)}function y(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return f(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 F(e){return"[object Date]"===toString.call(e)}var E=Array.isArray;function S(e){return"function"==typeof e}function R(e){return"[object RegExp]"===toString.call(e)}function q(e){return"boolean"==typeof e}function T(e){return!(!e||!(e.nodeName||e.prop&&e.attr&&e.find))}function w(e){return e&&e.window===e}function b(e){return void 0!==e}function H(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,a=typeof e;if(a===typeof t&&"object"===a){if(!E(e)){if(F(e))return!!F(t)&&(i=e.getTime(),s=t.getTime(),i===s||i!=i&&s!=s);if(R(e))return!!R(t)&&e.toString()===t.toString();if(w(e)||w(t)||E(t)||F(t)||R(t))return!1;for(n in o=Object.create(null),e)if(!S(e[n])){if(!H(e[n],t[n]))return!1;o[n]=!0}for(n in t)if(!(n in o)&&b(t[n])&&!S(t[n]))return!1;return!0}if(!E(t))return!1;if(r=e.length,e.length===t.length){for(n=0;n<r;n++)if(!H(e[n],t[n]))return!1;return!0}}return!1}function M(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(E(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 a(e,r);function s(e,t,r){if(--r<0)return"...";if(E(e))for(var n=0,o=e.length;n<o;n++)t.push(a(e[n],r));else if(g(e))for(var i in e)t[i]=a(e[i],r);else if(e&&"function"==typeof e.hasOwnProperty)for(var i in e)e.hasOwnProperty(i)&&(t[i]=a(e[i],r));else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=a(e[i],r));return t}function a(e,t){if(void 0===t&&(t=5),!v(e))return e;var r=n.indexOf(e);if(-1!==r)return o[r];if(w(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var i=!1,c=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(a(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(S(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===c&&(c=E(e)?[]:Object.create(Object.getPrototypeOf(e)),i=!0),n.push(e),o.push(c),i?s(e,c,t):c}}var x,k,D=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.isExpensiveFormat=function(e){switch(e){case"date":case"datetime":case"duration":return!0;default:return!1}},e.prototype.mergeCopyFields=function(e,t,r,n){for(var o=0,i=n;o<i.length;o++){var s=i[o],a=s.path;void 0===r[a]||"id"!==a&&void 0!==t[a]&&!this.compareFields(s.apiColumn.type,t[a],e[a])||(t[a]=this.clone(s.apiColumn.type,r[a]))}return t},e.prototype.formatRequest=function(e,t,r){for(var n={},o=0,i=r;o<i.length;o++){var s=i[o],a=s.id,c=s.apiColumn,u=c.type;c.readOnly||(this.compareFields(u,e[a],t[a])||(n[a]=this.formatRequestValue(u,t[a])))}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,a=i.apiColumn;a.readOnly||(r[s]=this.formatRequestValue(a.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,a=i.apiColumn;if("link"===a.type||"parenttype"===a.type||"parentid"===a.type||!a.readOnly){if(this.isExpensiveFormat(i.apiColumn.type)){var c=Object.getOwnPropertyDescriptor(t,s);if(void 0!==c&&void 0===c.value&&void 0!==c.get)continue}if(!this.compareFields(a.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],a=s.id,c=s.apiColumn;c.readOnly||(this.compareFields(c.type,e[a],t[a])||n.push({oldValue:e[a],newValue:t[a],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;e.hasOwnProperty(s)&&(this.isExpensiveFormat(i.apiColumn.type)||void 0!==e[s])&&(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],a=s.path;r[a]=void 0!==e[a]?e[a]:this.clone(s.apiColumn.type,t[a])}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":case"order":return t===r;default:return H(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":case"order":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 M(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}(),O=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}(),P=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.fetchColumnObject=function(e){return this.columnMap[e]},e.prototype.fetchValue=function(e,t,r){if(void 0!==this.items[e][t]){var n=this.columnMap[e][r],o=this.columnIndexMap[e][r];return this.apiFormatter.formatResponseValue(n.type,this.items[e][t].data[o])}},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.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){var n=this;if((void 0===r&&(r=!1),void 0!==this.items[e])&&void 0!==this.items[e][t]){for(var o=this.items[e][t].data,i={},s=function(t){var r=a.columns[e][t];a.apiFormatter.isExpensiveFormat(r.type)?Object.defineProperty(i,r.id,{enumerable:!0,configurable:!0,set:function(e){delete i[r.id],i[r.id]=e},get:function(){return delete i[r.id],i[r.id]=n.apiFormatter.formatResponseValue(r.type,o[t])}}):i[r.id]=a.apiFormatter.formatResponseValue(r.type,o[t])},a=this,c=0;c<o.length;c++)s(c);if(r){var u=this.items[e][t].links;for(var l in i.__links={},u)i.__links[l]=this.fetchObjectArray(l,r,u[l])}return i}},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.fetchColumnsObject=function(){return this.columnMap},e}(),_=function(){function e(e){this.transaction=e,this.compilation={create:{},delete:{},update:{},move:{}},this.processDelta()}return e.prototype.processDelta=function(){var e=this.transaction.getDelta();for(var t in e.deleted)for(var r=0,n=e.deleted[t];r<n.length;r++){var o=n[r];o.isLocal()||this.addDeleteEntry(o)}for(var i in e.created){var s=e.created[i];this.addCreateEntry(s)}for(var i in e.updated){s=e.updated[i];this.addUpdateEntry(s.entry)}for(var i in e.moved){s=e.moved[i];this.addMoveEntry(s.entry,s.to)}},e.prototype.getDefaultParent=function(){return{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e,t){p(this.compilation.move,[t.itemType,t.itemId],[{},[]]).push(e)},e.prototype.addDeleteEntry=function(e){p(this.compilation.delete,[e.itemType],[[]]).push(e)},e.prototype.addUpdateEntry=function(e){p(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=this.transaction.getParent(e.entry);null===t&&(t=this.getDefaultParent()),p(this.compilation.create,[t.itemType,t.itemId,e.entry.itemType,e.entry.itemId],[{},{},{},e])},e}(),j=function(){function e(e,t,r,n,o,i,s,a,c,u,l,h,p){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=o,this.errorHandler=i,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u,this.transaction=l,this.breakUpByParent=h,this.onAfterCreateCallback=p,this.itemIdConversionMap={},this.serverCache=this.transaction.getServerCache()}return e.prototype.execute=function(){var e=this,t=this.changesCompilationFactory.construct(this.transaction),r=t.compilation;return this.executeCreateRequests(t).then(function(){return e.executeMoveRequests(r.move)},this.errorHandler.reject).then(function(){return e.executeUpdateRequests(r.update)},this.errorHandler.reject).then(function(){return e.executeDeleteRequests(r.delete)},this.errorHandler.reject).then(function(){return e.itemIdConversionMap},this.errorHandler.reject)},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var o=n[r],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&&(r=this.itemIdConversionMap),void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.executeCreateRequests=function(e){for(var t=this,r=[],n=0,o=this.createRequestFactory.construct(e.compilation.create,this.transaction,this.breakUpByParent).run();n<o.length;n++){var i=o[n];r.push(this.executeCreateRequest(i).then(function(e){return void 0!==t.onAfterCreateCallback&&t.onAfterCreateCallback(t.itemIdConversionMap),e},this.errorHandler.reject))}return this.promiseService.all(r)},e.prototype.executeCreateRequest=function(e){var t=this;return this.apiRequestService.requestSkeleton(e.request).then(function(r){var n=t.changesDeltaFactory.construct(),o=r.map,i=r.fetchColumnsObject(),a=e.items;for(var c in a){var u=t.columnExpansionFactory.construct(c,e.request.columns[c],i);for(var l in a[c]){var h=a[c][l],p=t.getMapValue(c,parseInt(l,10),o);if(void 0!==p){var d=t.transaction.itemHandler.entries.get(c,l);d.itemId=p,t.serverCache.itemHandler.itemChanges[d.id]=t.serverCache.itemHandler.copyTransactionItemEntryChanges(t.transaction.itemHandler.itemChanges[d.id],d),t.serverCache.itemHandler.entries.add(d),t.transaction.itemHandler.entries.clearByItemId(c,Number(l)),t.serverCache.itemHandler.processApiResponse(n,r,h.itemType,Number(p),h.columns,u)}else console.warn("Create failed!",h)}}for(var c in o)for(var l in void 0===t.itemIdConversionMap[c]&&(t.itemIdConversionMap[c]={}),o[c])t.itemIdConversionMap[c][l]=o[c][l];for(var f=0,m=t.transaction.collectionHandler.entries.toArray();f<m.length;f++){var y=m[f],v=y.parent;if(null!==v){var g=t.getMapValue(v.itemType,v.itemId);void 0!==g&&(v.itemId=g,y.query=t.collectionEntryService.createQuery(y.options))}var C=y.getUpdatedItemColumns(t.itemIdConversionMap);s(C)&&(void 0!==C.id&&t.transaction.collectionHandler.onItemEntriesCreated(y,t.itemIdConversionMap[y.itemType]))}return t.serverCache.applyChangesDelta(n)},this.errorHandler.reject)},e.prototype.executeUpdateRequests=function(e){var t=[];for(var r in e)t.push(this.executeUpdateRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeUpdateRequest=function(e,t){var r=this,n={},o=this.requestColumnExpansionFactory.construct(),i=this.transaction.collectionHandler.getCollectionMatcher();for(var s in n[e]={},t){var a=t[s],c=n[e][s]={},u=d(this.transaction.tabRequestParameters,[e,s]);c.values=this.transaction.itemHandler.formatRequest(a),void 0!==u&&(c.parameters=u),o.expand(a.columns),i.expand(a,this.transaction.itemHandler.itemChanges[a.id].changes)}for(var l=0,h=i.getCollectionsWithFittingItems();l<h.length;l++){var p=h[l];o.expand(p.columns)}var f=o.get();return this.apiRequestService.updateItems(e,n,f).then(function(e){return r.serverCache.processResponse(e,!0,!1)},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){var r=this;return this.apiRequestService.delete(e,t.map(function(e){return e.itemId})).then(function(e){for(var n=r.changesDeltaFactory.constructInternalDelta(),o=e.items,i=[],s=0,a=t;s<a.length;s++){var u=a[s];c(u.itemId,o)?i.push(u):console.warn("Delete failed!",u)}return n.setItemsDeleted(i),r.serverCache.applyChangesFromParent(n,!0)},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e){var t=this,r=[],n=function(n,o){var i=e[n][o],s=t.getMapValue(n,o);r.push(t.apiRequestService.moveItems(n,void 0!==s?s:o,t.buildMoveRequest(i)).then(function(){for(var e=t.changesDeltaFactory.constructInternalDelta(),r=0,a=i;r<a.length;r++){var c=a[r];e.setItemUpdated(c,t.itemEntryService.getLinkFieldsByParent({itemType:n,itemId:void 0!==s?s:o},c.itemType))}return t.serverCache.applyChangesFromParent(e,!0)},t.errorHandler.reject))};for(var o in e)for(var i in e[o])n(o,+i);return this.promiseService.all(r)},e}(),L=function(){return function(e){this.columns=!0,this.parent=null,this.templateOptions={},this.templateColumns={},o(this,e)}}(),A=function(){return function(e){this.edit=!1,this.remote=!1,this.onChange=Nt,o(this,e)}}(),B=0,Q=function(){function e(e,t,r,n){this.factory=e,this.itemType=t,this.itemId=r,this.columns=n,this.id=++B,this.reloadQueued=!1}return e.prototype.queueReload=function(){return this.reloadQueued=!0,this},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.toJSON=function(){return{id:this.id,columns:this.columns}},e}(),U=function(){function e(e,t,r,n,o){this.factory=e,this.entry=t,this.options=r,this._isNew=n,this.transaction=o,this.columns=t.columns.response[t.columns.itemType],this.initial=this.transaction.itemHandler.itemChanges[t.id].initial,this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.getParent=function(e){return this.transaction.getParent(this.entry,e,this.fields)},e.prototype.callOnChange=function(e){var t=this,r=this.transaction.itemHandler.itemResources[this.entry.id];if(void 0!==r)for(var n=0,o=r;n<o.length;n++){var i=o[n];try{i.options.onChange(i,e,function(r){return t.compareItemField(r,e)},!1)}catch(e){this.factory.exceptionHandler(e)}}},e.prototype.compareItemField=function(e,t){var r=this.columns[e];if(void 0===r)throw new Error("Missing column in ItemResource.compareItemField");return this.factory.apiFormatter.compareFields(r.type,this.fields[e],t[e])},e.prototype.hasChanges=function(){return this.transaction.itemHandler.detectEntryChanges(this.entry.id)},e.prototype.setTransactionParameters=function(e){p(this.transaction.tabRequestParameters,[this.entry.itemType,this.entry.itemId],[{},e])},e.prototype.isNew=function(){return this._isNew},e.prototype.isLocal=function(){return this.entry.isLocal()},e.prototype.clearResource=function(){this.transaction.clearItemResource(this)},e.prototype.toJSON=function(){var e=[];for(var t in this.columns)e.push(t);return{columns:e,fields:this.fields,entry:this.entry}},e.prototype.getDerivedValue=function(e){return this.transaction.itemHandler.getDerivedValue(this.entry,e)},e.prototype.getDerivedValues=function(e){return this.transaction.itemHandler.getDerivedValues(this.entry,e)},e}(),V=(x=function(e,t){return(x=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}x(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),N=function(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.fields=i.itemHandler.itemChanges[r.id].changes,s}return V(t,e),t}(U),W=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)}}(),Y=function(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.localCopies=[],s.fields=i.itemHandler.itemChanges[r.id].changes,s}return W(t,e),t.prototype.isNew=function(){return this._isNew},t.prototype.copyFields=function(e){void 0===e&&(e={});var t=this.entry;return this.factory.apiFormatter.copyFields(this.fields,e,t.columns.main),e},t.prototype.setFields=function(e){var t=this,r=this.columns;for(var n in e){void 0===r[n]&&console.warn("setFields: no column found for",n)}var o=this.transaction.createChangesDelta();return o.setItemUpdated(this.entry,e),this.transaction.applyChangesDelta(o).then(function(){return t},this.factory.errorHandler.reject)},t}(U),J=function(){return function(e){this.columns=[],this.query=null,this.queryParams={},this.queryColumns=[],this.parent=null,this.deferRequest=!1,this.limit=null,this.entryKey=null,o(this,e)}}(),K=function(){return function(e){this.editItems=!1,this.remoteItems=!1,this.editCollection=!1,this.enableSave=!0,this.callOnAddWithInitialItems=!1,this.onItemsCreated=Nt,this.onChange=Nt,this.onAdd=Nt,this.onRemove=Nt,this.onAddInitial=Nt,this.onRemoveInitial=Nt,this.resourceKey=null,this.custom=null,o(this,e)}}(),z=0,X=function(){function e(e,t,r,n,o){this.collectionEntryService=e,this.columnSetFactory=t,this.keyService=r,this.itemType=n,this.options=o,this.id=z++,this.parent=null,this.reloadQueued=!1,this.parent=o.parent,this.query=this.collectionEntryService.createQuery(o),this.columns=this.columnSetFactory.constructStub(n,o.columns)}return e.prototype.isLocal=function(){var e=this.parent;return null!==e&&this.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.extendQuery=function(e){var t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.collectionEntryService.createQuery(t))},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.options.columns=this.columns.request)},e.prototype.expandRequestColumns=function(e){this.columns.expandRequestColumns(e),this.options.columns=this.columns.request},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}(),G=function(){function e(e,t,r,n){var o=this;this.factory=e,this.entry=t,this.options=r,this.transaction=n,this.itemIdMap={},this.items=[],this.itemIdMap={},this.columns=t.columns.response,this.onChange=function(e,t,r,n){e.compareItemField("id",t)||(delete o.itemIdMap[t.id],o.itemIdMap[e.entry.itemId]=e),o.options.onChange(e,t,function(r){return e.compareItemField(r,t)},n)},this.addItemResources(this.transaction.collectionHandler.collectionChanges[this.entry.id],!0),this.onConstruct()}return e.prototype.onConstruct=function(){},e.prototype.getIdArray=function(){return this.items.map(function(e){return e.entry.itemId})},e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.addItemResources=function(e,t){if(void 0===t&&(t=!1),0===e.length)return[];var r=this.items.map(function(e){return e.entry});e=e.filter(function(e){return-1===r.indexOf(e)});for(var n=this.transaction.createItemResources(e,{remote:this.options.remoteItems,edit:this.options.editItems,onChange:this.onChange}),o=0,i=n;o<i.length;o++){var s=i[o],a=s.entry.itemId;if(void 0!==this.itemIdMap[a])throw new Error("Added a resource of an entry that was already in the collection !");this.items.push(s),this.itemIdMap[a]=s}return t&&!this.options.callOnAddWithInitialItems||this.callOnAdd(n,t),n},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 n.clearResource(),r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e,t){void 0===t&&(t=!1);try{this.options.onAdd(e,this,t)}catch(e){this.factory.exceptionHandler(e)}},e.prototype.callOnRemove=function(e){try{this.options.onRemove(e,this)}catch(e){this.factory.exceptionHandler(e)}},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){if(void 0===this.entry.columns.response[this.entry.itemType][e])throw new Error("Trying to group on a column not requested by this collection! (column '"+e+"')");for(var n=0,o=t;n<o.length;n++){void 0===r[c=(a=o[n]).fields[e]]&&(r[c]=[]),r[c].push(a)}}if("function"==typeof e)for(var i=0,s=t;i<s.length;i++){var a,c;null!==(c=e(a=s[i]))&&(void 0===r[c]&&(r[c]=[]),r[c].push(a))}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){return this.transaction.collectionHandler.extendCollectionEntry(this.entry,e)},e.prototype.clearResource=function(e){if(void 0===e&&(e=!0),e)for(var t=0,r=this.items;t<r.length;t++){r[t].clearResource()}this.transaction.clearCollectionResource(this)},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,o){return e.call(this,t,r,n,o)||this}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){return e.call(this,t,r,n,o)||this}return ee(t,e),t.prototype.moveItems=function(e,t){if(this.options.enableSave)throw new Error("collectionResourceService: Cannot move items: saving enabled");return this.transaction.collectionHandler.moveItems(this.entry,t.entry,e)},t.prototype.removeItems=function(e){for(var t=this.factory.changesDeltaFactory.construct(),r=[],n=0,o=this.items;n<o.length;n++){var i=o[n].entry;-1!==e.indexOf(i.itemId)&&r.push(i)}t.setItemsDeleted(r),this.transaction.applyChangesDelta(t)},t.prototype.removeItem=function(e){return this.removeItems([e])},t.prototype.addItems=function(e){return this.transaction.itemHandler.createItems(this.entry.itemType,e,this.entry.parent)},t.prototype.addItem=function(e){return this.addItems([e])},t}(G),re=function(){return function(e,t,r,n,o){this.itemType=t,this.response=r,this.fields=r.fetchObject(t,r.links[t][0]);var i=r.fetchColumnsObject();this.responseColumns=e.columnUtil.mergeResponseColumns(i,o).merged,this.columns=e.columnSetFactory.constructFromResponse(t,i),this.columns=this.columns.expand(n[t],!1,o).merged}}(),ne=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)}}(),oe=function(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.fields=s.transaction.itemHandler.itemChanges[r.id].initial,s}return ne(t,e),t}(N),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(e){function t(t,r,n,o,i){var s=e.call(this,t,r,n,o,i)||this;return s.fields=i.itemHandler.itemChanges[r.id].changes,s}return ie(t,e),t}(N);!function(e){e.ITEMTABLE="itemtable",e.DIRECT="direct"}(k||(k={}));var ae,ce=function(){function e(e,t,r,n,o,i,s,a){this.columnUtil=e,this.apiFormatter=t,this.itemEntryFactory=r,this.promiseService=n,this.errorHandler=o,this.requestColumnExpansionFactory=i,this.transaction=a,this.entries=s.construct(this.transaction)}return e.prototype.getDerivedValues=function(e,t){for(var r=e,n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),o=0,i=t;o<i.length;o++){var s=i[o],a=r.columns.response[r.itemType][s];if(void 0===a)throw new Error("Column '"+s+"' not found on entry in ItemResource.getDerivedValue");if(null===a.itemType)throw new Error("Column '"+s+"' doesn't have children in ItemResource.getDerivedValue");var c=n[s];if(null===c)return;if(void 0===(r=this.transaction.getLocalItemEntryByItemId(a.itemType,c)))throw new Error("Derived itemEntry "+a.itemType+":"+c+" couldn't be found");n=this.transaction.getItemChangesRecursively(r.id,!1)}return n},e.prototype.getDerivedValue=function(e,t){"string"==typeof t&&(t=this.columnUtil.parseConfigColumn(t));var r=this.getDerivedValues(e,t.slice(0,-1));if(void 0!==r)return r[t[t.length-1]]},e.prototype.clearItemEntry=function(e){this.entries.clear(e),delete this.itemChanges[e.id]},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)throw new Error("You should use fields[columnId] instead of derived['columnId>id'] to get the id of a derived item");for(var a={},c=0,u=e;c<u.length;c++){var l=u[c];null!==(p=this.getItemIdByColumn(l,t,r))&&(void 0===a[p]&&(a[p]=[]),a[p].push(l))}if(!s(a))return this.promiseService.when();var h=[];for(var p in a)h.push(+p);for(var d=[],f=0,m=o;f<m.length;f++){var y=m[f];d.push(y.id)}return this.fetchItemEntries(t.itemType,h,new L({columns:d})).then(function(){return n.resolveDerivedValues(e,o)},this.errorHandler.reject)},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.createItemEntry=function(e){var t=this.itemEntryFactory.construct(e.itemId,e.columns);return this.entries.add(t),t},e.prototype.getItemIdByColumn=function(e,t,r){return 0===t.level?void 0!==r&&void 0!==r.updated[e.id]?r.updated[e.id].changes.fields[t.path]:this.transaction.getChangesFromItemChanges(this.itemChanges[e.id])[t.path]:this.getDerivedValue(e,t.path)},e.prototype.expandColumnsWithCollectionColumns=function(e,t){var r=this.requestColumnExpansionFactory.construct();void 0!==t&&r.expandWithRequestColumns(e,t);for(var n=function(t){for(var n=0,o=t.collectionHandler.entries.getByItemType(e);n<o.length;n++){var i=o[n];r.expandWithRequestColumns(e,i.options.queryColumns),r.expandWithRequestColumns(e,i.options.columns)}},o=function(e){for(var t=0,r=e;t<r.length;t++){var i=r[t];n(i),o(i.children)}},i=0,s=this.transaction.getTransactionChain();i<s.length;i++){var a=s[i];n(a)}return o(this.transaction.children),r.get()[e]},e}(),ue=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)}}(),le=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v){var g=e.call(this,p,d,f,h,c,y,m,v)||this;return g.changesDeltaFactory=t,g.exceptionHandler=r,g.templateCache=n,g.columnExpansionFactory=o,g.columnHandler=i,g.columnSetFactory=s,g.columnSubsetCacheFactory=a,g.itemEntryService=u,g.keyService=l,g.transaction=v,g.deletedItems={},g.itemChanges={},g.itemResources={},g}return ue(t,e),t.prototype.copyTransactionItemEntryChanges=function(e,t){return{initial:this.apiFormatter.copyFields(e.initial,{},t.columns.main),changes:this.apiFormatter.copyFields(e.changes,{},t.columns.main)}},t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t),n=this.itemEntryService.getLocalDefaultValues();for(var o in n)t.fields[o]=n[o];var i=this.apiFormatter.copyFields(t.fields,{},t.columns.main);return this.itemChanges[r.id]={initial:t.fields,changes:i},this.itemChanges[r.id].initial.id=r.itemId,this.itemChanges[r.id].changes.id=r.itemId,r},t.prototype.formatRequest=function(e){var t=e.columns.main;return e.isLocal()?this.apiFormatter.formatRequestLocal(this.itemChanges[e.id].changes,t):this.apiFormatter.formatRequest(this.itemChanges[e.id].initial,this.itemChanges[e.id].changes,t)},t.prototype.createItems=function(e,t,r){for(var n,o=this,i=[],s=this.changesDeltaFactory.construct(),a=((n={})[e]=this.expandColumnsWithCollectionColumns(e),n),c=function(t){var n=u.keyService.getLocalId();i.push(u.templateCache.fetchTemplate(e,n,{},a,r).then(function(i){o.resolveLocal(s,e,n,r,i,function(){return!0},function(r,n){if(r===e)for(var o in t)n[o]=t[o]})},u.errorHandler.reject))},u=this,l=0,h=t;l<h.length;l++){c(h[l])}return this.promiseService.all(i).then(function(){return o.transaction.applyChangesDelta(s)})},t.prototype.clearItemEntry=function(t){e.prototype.clearItemEntry.call(this,t),delete this.itemResources[t.id]},t.prototype.addResource=function(e){var t=this.itemResources[e.entry.id];void 0===t&&(t=this.itemResources[e.entry.id]=[]),t.push(e)},t.prototype.clearResource=function(e){var t=this.itemResources[e.entry.id];if(void 0!==t){var r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&delete this.itemResources[e.entry.id]}},t.prototype.detectChanges=function(){for(var e in this.entries.entriesByEntryId)return!0;for(var t in this.itemChanges){if(this.detectEntryChanges(Number(t)))return!0}return!1},t.prototype.detectEntryChanges=function(e){var t=this.transaction.getLocalItemEntry(e),r=this.itemChanges[e];return this.apiFormatter.hasChanges(r.initial,r.changes,t.columns.main)},t.prototype.processItemEntryChanges=function(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n=!1);var o=e.entry,i=e.changes;if(void 0===this.itemChanges[o.id])return null;null!==i.expandedColumns&&(o.columns=i.expandedColumns.merged);var s=this.itemChanges[o.id],a=this.apiFormatter.copyFields(s.changes,{},o.columns.main),c=this.apiFormatter.hasChanges(i.fields,s.changes,o.columns.main);if(t?this.apiFormatter.copyFields(i.fields,s.changes,o.columns.main):this.apiFormatter.mergeCopyFields(s.initial,s.changes,i.fields,o.columns.main),r&&this.apiFormatter.copyFields(i.fields,s.initial,o.columns.main),void 0===i.fields.displayname){var u=this.itemEntryService.getDisplayName(o,s.changes);void 0!==u&&(s.changes.displayname=u)}if(c){var l=this.itemResources[o.id];if(void 0!==l)for(var h=function(e){try{e.options.onChange(e,a,function(t){return e.compareItemField(t,a)},n)}catch(e){p.exceptionHandler(e)}},p=this,d=0,f=l;d<f.length;d++){h(f[d])}}return a},t.prototype.cloneItemEntries=function(e,t,r){void 0===t&&(t={});var n=this.changesDeltaFactory.construct();this.itemEntryService.batchExpandConversionMap(e,t);for(var o=0,i=e;o<i.length;o++){var s=i[o];this.cloneItemEntry(n,s,{},t,r)}return this.transaction.applyChangesDelta(n)},t.prototype.cloneItemEntry=function(e,t,r,n,o){void 0===r&&(r={}),void 0===n&&(n={});var i=this.transaction.getLocalItemEntryChangesTuple(t.id),s=this.itemEntryService.expandConversionMap(t,n),a=this.transaction.getParent(t),c=null;if(null!==a){var u=this.itemEntryService.getConversionValue(a.itemType,a.itemId,n);c={itemType:a.itemType,itemId:u||a.itemId}}var l=this.apiFormatter.copyFields(i.changes.changes,{},t.columns.main),h=this.updateItemValues(l,c,t.columns.item,n);for(var p in h)l[p]=h[p];for(var p in r)l[p]=r[p];return void 0!==o&&o(t,l),e.setItemCreated(s,r,t.columns),s},t.prototype.fetchItemEntriesByQuery=function(e,t,r){return this.transaction.getServerCache().itemHandler.fetchItemEntriesByQuery(e,t,r)},t.prototype.fetchItemEntry=function(e,t,r){var n=this;if(!this.keyService.isLocalId(t))return this.transaction.getServerCache().itemHandler.fetchItemEntry(e,t,r);if(void 0===this.entries.get(e,t))return this.transaction.parent instanceof Ke?this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(e)):this.transaction.parent.itemHandler.fetchItemEntry(e,t,r);r.columns=this.expandColumnsWithCollectionColumns(e,r.columns);var o=this.changesDeltaFactory.construct(),i=this.columnSubsetCacheFactory.construct(r.columns);return this.fetchLocalItemEntryData(o,e,t,i,r).then(function(e){return n.transaction.applyChangesDelta(o).then(function(){return e},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.fetchNewItemEntry=function(e,t,r){var n=this;return void 0!==this.entries.get(e,t)?this.errorHandler.reject(this.itemEntryService.createExistingLocalItemError(e)):this.templateCache.fetchTemplate(e,t,r.templateOptions,r.templateColumns,r.parent).then(function(o){if(void 0!==n.entries.get(e,t))return n.errorHandler.reject(n.itemEntryService.createExistingLocalItemError(e));var i=n.changesDeltaFactory.construct();return n.resolveLocal(i,e,t,r.parent,o),n.transaction.applyChangesDelta(i)},this.errorHandler.reject)},t.prototype.fetchItemEntries=function(e,t,r){for(var n=[],o=[],i=0,s=t;i<s.length;i++){var a=s[i];this.keyService.isLocalId(a)?o.push(a):n.push(a)}return this.promiseService.all({remote:this.transaction.getServerCache().itemHandler.fetchItemEntries(e,n,r),local:this.fetchLocalItemEntries(e,o,r)}).then(function(e){return e.remote.concat(e.local)})},t.prototype.fetchTitle=function(e,t){var r=this,n=this.itemEntryService.getTitleField(e);return this.fetchItemEntry(e,t,new L({columns:[n]})).then(function(e){return r.transaction.getItemChangesRecursively(e.id,!1)[n]},this.errorHandler.reject)},t.prototype.resolveLocalItemEntry=function(e,t,r,n){var o=this;if(r.run(t.columns))return this.promiseService.when(t);var i=this.getColumnDifference(t,n.columns);return this.columnHandler.fetch(t.itemType,i).then(function(r){return o.expandLocalItemEntries(e,t.itemType,[t],i,r)},this.errorHandler.reject).then(function(){return t},this.errorHandler.reject)},t.prototype.createLocalEntries=function(e,t,r,n,o,i,s){var a=this;void 0===i&&(i=function(){return!0});var c=n.response,u={},l=function(t,r,h){var p={itemType:t,itemId:r},d=c.items[t][h].links;for(var f in d)if(d.hasOwnProperty(f)){void 0===u[f]&&(u[f]=a.columnSetFactory.construct(f,!0,n.responseColumns));for(var m=0,y=d[f];m<y.length;m++){var v=y[m],g=c.fetchObject(f,v);if(i(f,g)){var C=o[f][v],I=a.updateItemValues(g,p,u[f].item,o);for(var F in I)g[F]=I[F];void 0!==s&&s(f,g,o),e.setItemCreated(C,g,u[f],p),l(f,C,v)}}}};l(t,r,c.links[t][0])},t.prototype.expandLocalItemEntries=function(e,t,r,n,o){if(0===r.length)return this.promiseService.when(r);for(var i=this.columnExpansionFactory.construct(t,n,o),s=0,a=r;s<a.length;s++){var c=a[s],u=i.run(c.columns);null!==u&&this.expandLocalItemEntry(e,c,u)}return this.resolveDerivedValues(r,i.aggregateRootColumns())},t.prototype.updateItemValues=function(e,t,r,n){for(var o={},i=0,s=r;i<s.length;i++){var a=s[i],c=a.id,u=a.apiColumn,l=void 0;"link"===u.type&&void 0===e[c]?null!==t&&(l=t.itemId):l=this.itemEntryService.getConversionValue(u.itemType,e[c],n),void 0!==l&&(o[c]=l)}return o},t.prototype.fetchLocalItemEntryData=function(e,t,r,n,o){var i=this.entries.get(t,r);return void 0===i?this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(t)):this.resolveLocalItemEntry(e,i,n,o)},t.prototype.fetchLocalItemEntries=function(e,t,r){var n=this;r.columns=this.expandColumnsWithCollectionColumns(e,r.columns);for(var o=this.changesDeltaFactory.construct(),i=this.columnSubsetCacheFactory.construct(r.columns),s=[],a=[],c=0,u=t;c<u.length;c++){var l=u[c];if(void 0!==this.entries.get(e,l))s.push(this.fetchLocalItemEntryData(o,e,l,i,r));else{if(this.transaction.parent instanceof Ke)return this.errorHandler.reject(this.itemEntryService.createUnfoundLocalItemError(e));a.push(l)}}if(a.length>0){if(this.transaction.parent instanceof Ke)throw new Error("Tried looking for local entries on the serverCache");s.push(this.transaction.parent.itemHandler.fetchLocalItemEntries(e,a,r))}return this.promiseService.all(s).then(function(){return n.transaction.applyChangesDelta(o).then(function(){return t.map(function(t){return n.transaction.getLocalItemEntryByItemId(e,t)})},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.getColumnDifference=function(e,t){return this.columnUtil.mergeRequestColumns(e.columns.request,t).difference},t.prototype.resolveLocal=function(e,t,r,n,o,i,s){void 0===i&&(i=function(){return!0});var a=this.itemEntryService.createLocalConversionMap(t,r,!0,o.response),c=this.apiFormatter.copyFields(o.fields,{},o.columns.main),u=this.updateItemValues(c,n,o.columns.item,a);for(var l in u)c[l]=u[l];void 0!==s&&s(t,c,a),e.setItemCreated(r,c,o.columns,n),this.createLocalEntries(e,t,r,o,a,i,s)},t.prototype.expandLocalItemEntry=function(e,t,r){var n=r.difference.main;if(t.columns=r.merged,0!==n.length){var o=this.getLocalValues(t,n);s(o)&&e.setItemUpdated(t,o,r)}},t.prototype.getLocalValues=function(e,t){for(var r=this.transaction.getParent(e),n=this.transaction.getChangesFromItemChanges(this.itemChanges[e.id]),o={},i=0,s=t;i<s.length;i++){var a=s[i],c=a.id;if(void 0===n[c]){var u=a.apiColumn.type;o[c]="link"===u&&null!==r?r.itemId:this.apiFormatter.getDefaultValue(u)}}return o},t}(ce),he=function(){function e(e,t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k){this.core=e,this.columnCache=t,this.requestBufferManager=r,this.requestColumnExpansionFactory=n,this.queryMatcherFactory=o,this.authInterface=i,this.changesDeltaFactory=s,this.lockService=a,this.moduleChangesCompilationFactory=c,this.collectionResourceFactory=u,this.itemResourceFactory=l,this.templateCache=h,this.itemCacheFactory=p,this.collectionCacheFactory=d,this.errorHandler=f,this.exceptionHandler=m,this.promiseService=y,this.apiRequestService=v,this.columnExpansionFactory=g,this.columnHandler=C,this.columnSetFactory=I,this.columnSubsetCacheFactory=F,this.columnUtil=E,this.itemEntryFactory=S,this.itemEntryService=R,this.keyService=q,this.collectionEntryFactory=T,this.collectionEntryService=w,this.collectionMatcherFactory=b,this.queryParserFactory=H,this.queryService=M,this.apiFormatter=x,this.linkTreeService=k,this.children=[]}return e.prototype.createChild=function(e){var t=new Ie(this.core,this.columnCache,this.requestBufferManager,this.requestColumnExpansionFactory,this.queryMatcherFactory,this.authInterface,this.changesDeltaFactory,this.lockService,this.moduleChangesCompilationFactory,this.collectionResourceFactory,this.itemResourceFactory,this.templateCache,this.itemCacheFactory,this.collectionCacheFactory,this.errorHandler,this.exceptionHandler,this.promiseService,this.apiRequestService,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnSubsetCacheFactory,this.columnUtil,this.itemEntryFactory,this.itemEntryService,this.keyService,this.collectionEntryFactory,this.collectionEntryService,this.collectionMatcherFactory,this.queryParserFactory,this.queryService,this.apiFormatter,this.linkTreeService,this,e);return this.children.push(t),t},e.prototype.onChildDestroy=function(e){var t=this.children.indexOf(e);-1!==t&&this.children.splice(t,1)},e.prototype.getTransactionChain=function(){var e=[],t=this;do{e.push(t),t=t.parent}while(null!==t);return e},e.prototype.getCurrentCollectionEntryCache=function(){return this.collectionHandler.entries},e.prototype.getCurrentItemEntryCache=function(){return this.itemHandler.entries},e.prototype.getParentFromFields=function(e,t){if(void 0===t)return null;if(null!==e.columns.link)return{itemType:e.columns.link.apiColumn.itemType,itemId:t[e.columns.link.id]};var r=e.columns.response[e.itemType];return void 0!==r.itemtype&&void 0!==r.item?{itemType:t.itemtype,itemId:t.item}:null},e.prototype._applyChangesDelta=function(e){for(var t=this,r=this.changesDeltaFactory.constructInternalDelta(),n=[],o=[],i=function(e){var t=s.itemHandler.createItemEntry(e);n.push(t),r.setItemCreated(t,s.getChangesFromItemChanges(s.itemHandler.itemChanges[t.id])),o.push(function(e){return e.setItemDeleted(t)})},s=this,a=0,c=e.created;a<c.length;a++){i(c[a])}var u=function(t){var n=e.updated[t],i=l.itemHandler.processItemEntryChanges(n,!0);if(r.setItemUpdated(n.entry,n.changes.fields,n.changes.expandedColumns),null!==i&&o.push(function(e){return e.setItemUpdated(n.entry,i)}),null!==n.changes.parent&&r.setItemMoved(n.entry,n.changes.parent),l.itemHandler instanceof le){var s=l.itemHandler.deletedItems[n.entry.itemType];if(void 0===s)return"continue";var a=s.indexOf(n.entry);a>-1&&s.splice(a,1)}},l=this;for(var h in e.updated)u(h);return{result:{created:n,rollback:function(){for(var e=t.changesDeltaFactory.construct(),r=0,n=o;r<n.length;r++){(0,n[r])(e)}return t.applyChangesDelta(e)}},internalChangesDelta:r,rollbackFunctions:o}},e.prototype.fetchUpdatedDerivedValuesFromDelta=function(e){var t=[];for(var r in e.updated){for(var n=e.updated[r],o=[],i=0,s=n.entry.columns.root;i<s.length;i++){var a=s[i];n.changes.fields.hasOwnProperty(a.id)&&n.changes.fields[a.id]!==this.getChangesFromItemChanges(this.itemHandler.itemChanges[n.entry.id])[a.id]&&o.push(a)}0!==o.length&&t.push(this.itemHandler.resolveDerivedValues([n.entry],o,e))}return this.promiseService.all(t)},e}(),pe=function(){function e(e,t,r){this.queryMatcherFactory=e,this.transaction=t,this.getCollectionEntries=r,this.map={}}return e.prototype.expand=function(e,t){var r=this.queryMatcherFactory.construct(e.itemType,t,this.transaction.getParent(e));return this._expand(e,function(e){return r.matchQuery(e.query.object)})},e.prototype.processDelta=function(e){for(var t in e.deleted)for(var r=0,n=e.deleted[t];r<n.length;r++){var o=n[r];this._expand(o,function(){return!1})}var i=function(t){var r=e.created[t],n=s.queryMatcherFactory.construct(r.entry.itemType,r.fields,s.transaction.getParent(r.entry));s._expand(r.entry,function(e){return n.matchQuery(e.query.object)})},s=this;for(var a in e.created)i(a);var c=function(t){var r=e.moved[t];u._expand(r.entry,function(e){return e.matchParent(r.to.itemType,r.to.itemId)})},u=this;for(var a in e.moved)c(a);var l=function(t){var r=e.updated[t],n={},o=h.transaction.getItemChangesRecursively(Number(t),!1),i=function(e,t){var r=Object.getOwnPropertyDescriptor(e,t);void 0!==r?Object.defineProperty(n,t,r):n[t]=e[t]};for(var s in o)i(o,s);for(var s in r.changes.fields)i(r.changes.fields,s);var a=h.queryMatcherFactory.construct(r.entry.itemType,n,h.transaction.getParent(r.entry));h._expand(r.entry,function(e){return a.matchQuery(e.query.object)})},h=this;for(var a in e.updated)l(a);return this},e.prototype.hasFittingItems=function(e){for(var t in e)if(!0===e[t].isMatch)return!0;return!1},e.prototype._expand=function(e,t){for(var r=this.map,n=e.itemId,o=0,i=this.getCollectionEntries(e.itemType);o<i.length;o++){var s=i[o],a=s.id,c=void 0;void 0===r[a]&&(r[a]={collection:s,matches:{}}),void 0===(c=r[a].matches)[n]&&(c[n]={item:e,isMatch:t(s)})}return this},e}(),de=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)}}(),fe=function(e){function t(t,r,n){return e.call(this,t,r,n)||this}return de(t,e),t.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},t}(pe),me=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)}}(),ye=function(e){function t(t,r,n,o){var i=e.call(this,r,n,o)||this;return i.apiRequestService=t,i}return me(t,e),t.prototype.removeFromAndAddToCollections=function(e){var t=this;void 0===e&&(e=!1);var r=function(r){var o,i=n.map[r],s=i.collection,a=n.groupItemEntries(i.matches);n.transaction.collectionHandler.removeItemEntriesFromCollectionChanges(s,a.notFitting,e),n.transaction.collectionHandler.addItemEntriesToCollectionChanges(s,a.fitting,e),a.maybe.length>0&&n.apiRequestService.query(s.itemType,s.query.object,(o={},o[s.itemType]=["id"],o)).then(function(r){t.transaction.collectionHandler.addItemEntriesToCollectionChanges(s,a.maybe.filter(function(e){return r.links[s.itemType].indexOf(e.itemId)>-1}),e)})},n=this;for(var o in this.map)r(o)},t.prototype.groupItemEntries=function(e){var t=[],r=[],n=[];for(var o in e){var i=e[o],s=i.item,a=i.isMatch;!0===a?t.push(s):!1===a?r.push(s.itemId):n.push(s)}return{fitting:t,notFitting:r,maybe:n}},t}(fe),ve=function(){function e(e,t,r){this.errorHandler=e,this.exceptionHandler=t,this.promiseService=r,this.callbacks={onBeforeSave:[],onSaveSuccess:[]}}return e.prototype.registerCallback=function(e,t,r,n,o){var i=this;return void 0===n&&(n="always"),void 0===o&&(o=100),this.getPriorityLevel(e,o)[t]={callback:r,condition:n},function(){delete i.getPriorityLevel(e,o)[t]}},e.prototype.executeCallbacks=function(e,t,r){for(var n=this.callbacks[e],o=r?"onClose":"skipOnClose",i=this.promiseService.when(),s=0,a=n;s<a.length;s++){var c=a[s];i=i.then(this.executeCallbacksPriorityLevel(c[1],o,t),this.errorHandler.reject)}return i},e.prototype.getPriorityLevel=function(e,t){for(var r,n=this.callbacks[e],o=0;o<n.length;o++){var i=n[o];if(!(i[0]<t))return i[0]===t?i[1]:(r={},n.splice(o,0,[t,r]),r)}return r={},n.push([t,r]),r},e.prototype.executeCallbacksPriorityLevel=function(e,t,r){var n=this;return function(){var o={};for(var i in e){var s=e[i];if(s.condition===t||"always"===s.condition)try{o[i]=r(s.callback)}catch(e){n.exceptionHandler(e)}}return n.promiseService.all(o)}},e}(),ge=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)}}(),Ce=function(){return(Ce=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},Ie=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D,O,P){var _=e.call(this,t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D)||this;return _.id=P,_.tabRequestParameters={},_.isSaving=!1,_.hasChanges=!1,_.changesInterval=null,_.parent=O,_.itemHandler=new le(a,y,p,C,I,F,E,m,q,T,v,S,k,R,d,o,_),_.collectionHandler=new pt(o,S,E,C,a,f,b,H,I,m,_.itemHandler,T,v,y,_),_.eventHandler=new ve(m,y,v),_}return ge(t,e),t.prototype.destroy=function(){this.parent.onChildDestroy(this)},t.prototype.createChangesDelta=function(){return this.changesDeltaFactory.construct()},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;for(var o in void 0===t&&(t=!1),void 0===r&&(r=!1),e.updated){var i=e.updated[o];this.itemHandler.processItemEntryChanges(i,t,!0,r)}for(var s in e.deleted)for(var a=0,c=e.deleted[s];a<c.length;a++){var u=c[a];if(this.itemHandler.entries.clear(u),delete this.itemHandler.itemChanges[u.id],delete this.itemHandler.itemResources[u.id],void 0!==this.itemHandler.deletedItems[u.itemType]){var l=this.itemHandler.deletedItems[u.itemType].indexOf(u);-1!==l&&this.itemHandler.deletedItems[u.itemType].splice(l,1)}}new ye(this.apiRequestService,this.queryMatcherFactory,this,function(e){return n.collectionHandler.getAllCollectionsByItemType(e)}).processDelta(e).removeFromAndAddToCollections(r);for(var h=0,p=this.children;h<p.length;h++){p[h].applyChangesFromParent(e)}this.hasChanges=!1,this.detectChanges()},t.prototype.applyChangesDelta=function(t){var r=this;return 0!==t.created.length||s(t.updated)||s(t.deleted)?this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var n=e.prototype._applyChangesDelta.call(r,t),o=n.result,i=n.internalChangesDelta,s=n.rollbackFunctions;for(var a in t.deleted)for(var c=function(e){r.itemHandler.entries.clear(e);var n=r.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete r.itemHandler.itemChanges[e.id],delete r.itemHandler.itemResources[e.id],void 0===r.itemHandler.deletedItems[e.itemType]&&(r.itemHandler.deletedItems[e.itemType]=[]),r.itemHandler.deletedItems[e.itemType].push(e),i.setItemDeleted(e),s.push(function(t){t.setItemUpdated(e,n.changes)})},u=0,l=t.deleted[a];u<l.length;u++){c(l[u])}new ye(r.apiRequestService,r.queryMatcherFactory,r,function(e){return r.collectionHandler.getAllCollectionsByItemType(e)}).processDelta(i).removeFromAndAddToCollections();for(var h=0,p=r.children;h<p.length;h++){p[h].applyChangesFromParent(i)}return r.hasChanges=!1,r.detectChanges(),o}):this.promiseService.when({created:[],rollback:Nt})},t.prototype.getServerCache=function(){return this.parent.getServerCache()},t.prototype.getParent=function(e,t,r){var n;if(void 0===t&&(t=!1),void 0!==r)n=r;else{var o=this.itemHandler.itemChanges[e.id];void 0!==o&&(n=o[t?"initial":"changes"])}if(void 0!==n){var i=this.getParentFromFields(e,n);if(null!==i)return i}return this.parent.getParent(e,t)},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);return void 0!==r&&void 0!==n?t?this.apiFormatter.copyFields(r.changes,{},n.columns.main):r.changes:this.parent.getItemChangesRecursively(e,t)},t.prototype.clearItemResource=function(e){return this.itemHandler.clearResource(e)},t.prototype.clearCollectionResource=function(e){return this.collectionHandler.clearResource(e)},t.prototype.isLockable=function(){return void 0!==this.rootItem&&this.rootItem.isLockable()},t.prototype.disableChangesWatcher=function(){null!==this.changesInterval&&(clearInterval(this.changesInterval),this.changesInterval=null)},t.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=window.setInterval(function(){e.detectChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},t.prototype.save=function(e,t,r,n){var o,i=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 i.eventHandler.executeCallbacks("onBeforeSave",function(e){return e(i)},e)},this.errorHandler.reject).then(function(){return i.tabRequestParameters=Ce({},i.tabRequestParameters,t),i.parent.applyChangesFromChild(i,r,n)}).then(function(t){return o=t,i.tabRequestParameters={},i.isLockable()&&i.lockService.clearLock(i.rootItem),i.hasChanges=!1,i.eventHandler.executeCallbacks("onSaveSuccess",function(e){return e(i,o)},e)},this.errorHandler.reject).then(function(){return e||i.enableChangesWatcher(),i.isSaving=!1,o},this.errorHandler.reject).catch(function(e){return i.isSaving=!1,i.errorHandler.reject(e)}))},t.prototype.detectChanges=function(){return!!this.hasChanges||(this.itemHandler.detectChanges()?this.hasChanges=!0:this.hasChanges=!1)},t.prototype.clearItem=function(e){this.clearItemEntry(e.entry)},t.prototype.clearItemEntry=function(e){return this.itemHandler.clearItemEntry(e)},t.prototype.clearCollection=function(e){return this.collectionHandler.clearEntry(e.entry)},t.prototype.onBeforeSave=function(e,t,r,n){return this.eventHandler.registerCallback("onBeforeSave",e,t,r,n)},t.prototype.onSaveSuccess=function(e,t,r,n){return this.eventHandler.registerCallback("onSaveSuccess",e,t,r,n)},t.prototype.getModuleChanges=function(){if(void 0===this.rootItem)throw new Error("No root item for transaction cache "+this);return this.moduleChangesCompilationFactory.construct(this).process()},t.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])}},t.prototype.cloneCollection=function(e,t,r){var n=t.parent;if(null===n||void 0===n)throw new Error("Parent required for cloneCollection");return this.createCollectionResource(this.collectionHandler.cloneCollectionEntry(e.entry,n,r),t)},t.prototype.cloneItem=function(e,t){var r=this,n=this.changesDeltaFactory.construct();return this.itemHandler.cloneItemEntry(n,e.entry),this.applyChangesDelta(n).then(function(e){var n=e.created[0];return r.createItemResource(n,t,!1)})},t.prototype.getAllLinkCollections=function(e,t,r){var n,o=this;return this.apiRequestService.query(e,{},(n={},n[e]=["id"],n)).then(function(n){return o.getLinkCollections(e,n.links[e],t,r)},this.errorHandler.reject)},t.prototype.getLinkCollectionsFromDef=function(e,t,r){var n=this;return this.collectionHandler.fetchLinkedCollectionEntries(e,t,r.itemType,r.options.entry).then(function(e){return n.createCollectionResources(e,r.options.resource)},this.errorHandler.reject)},t.prototype.getLinkCollections=function(e,t,r,n){var o=this;return this.collectionHandler.fetchLinkedCollectionEntries(e,t,r,new J(n)).then(function(e){return o.createCollectionResources(e,n)},this.errorHandler.reject)},t.prototype.getCollectionFromDef=function(e){var t=this;return this.collectionHandler.fetchCollectionEntry(e.itemType,e.options.entry).then(function(r){return t.createCollectionResource(r,e.options.resource)},this.errorHandler.reject)},t.prototype.getCollection=function(e,t){var r=this;return this.collectionHandler.fetchCollectionEntry(e,new J(t)).then(function(e){return r.createCollectionResource(e,new K(t))},this.errorHandler.reject)},t.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:new J(t),resource:new K(t)}}},t.prototype.getLinkCollectionsDef=function(e,t,r){return{itemType:e,linkField:t,options:{entry:new J(r),resource:new K(r)}}},t.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.itemHandler.entries.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)},t.prototype.getDuplicateById=function(e,t,r,n,o){return void 0===r&&(r={}),void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=t),this.getNewResourceWithId(e,this.keyService.getLocalDuplicateId(),r,n,o)},t.prototype.getNewResourceWithId=function(e,t,r,n,o){var i=this;return void 0===n&&(n=!1),r.edit=!0,this.itemHandler.fetchNewItemEntry(e,t,new L(r)).then(function(s){for(var a,c={},u=0,l=s.created;u<l.length;u++){var h=l[u];h.itemType!==e||h.itemId!==t?(void 0===c[h.itemType]&&(c[h.itemType]=[]),c[h.itemType].push(h)):a=h}if(void 0===a)throw new Error("The ItemEntry with the requested ItemId was not in the template response");var p=i.createItemResource(a,r,o,!0);return n?{main:p,linked:i.processLinkedItems(c,r)}:p},this.errorHandler.reject)},t.prototype.getNewResource=function(e,t,r,n){return void 0===t&&(t={}),this.getNewResourceWithId(e,this.keyService.getLocalId(),t,r,n)},t.prototype.getItemsByQuery=function(e,t,r){var n=this;void 0===r&&(r={});var o=new L(r);return this.itemHandler.fetchItemEntriesByQuery(e,t,o).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},t.prototype.getItemsById=function(e,t,r){var n=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntries(e,t,new L(r)).then(function(e){return n.createItemResources(e,r)},this.errorHandler.reject)},t.prototype.getItemById=function(e,t,r,n){var o=this;return void 0===r&&(r={}),this.itemHandler.fetchItemEntry(e,t,new L(r)).then(function(e){return o.createItemResource(e,r,n)},this.errorHandler.reject)},t.prototype.fetchTitle=function(e,t){return this.itemHandler.fetchTitle(e,t)},t.prototype.applyChangesFromChild=function(e,t,r){var n=this,o=this.linkTreeService.get(),i=e.getDelta();for(var s in i.moved){var a=i.moved[s];i.setItemUpdated(a.entry,{},null,a.to),delete i.moved[s]}for(var s in i.updated){a=i.updated[s];void 0===this.itemHandler.itemChanges[s]?this.itemHandler.itemChanges[s]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry):this.itemHandler.processItemEntryChanges(a,!0)}for(var s in i.created){a=i.created[s];this.itemHandler.entries.add(a.entry),e.itemHandler.entries.clear(a.entry);var c=this.itemHandler.itemChanges[a.entry.id]=this.itemHandler.copyTransactionItemEntryChanges(e.itemHandler.itemChanges[s],a.entry),u=this.itemEntryService.getDisplayName(a.entry,c.changes);if(void 0!==u&&(c.changes.displayname=u),void 0!==this.rootItem){var l=o[this.rootItem.itemType][a.entry.itemType];void 0!==l&&(l.type===k.ITEMTABLE?(c.changes.itemtype=this.rootItem.itemType,c.changes.item=this.rootItem.itemId):l.type===k.DIRECT&&(c.changes[l.field]=this.rootItem.itemId))}}for(var h in i.deleted){void 0===this.itemHandler.deletedItems[h]&&(this.itemHandler.deletedItems[h]=[]);for(var p=0,d=i.deleted[h];p<d.length;p++){var f=d[p];f.isLocal()||(this.itemHandler.entries.clear(f),this.itemHandler.deletedItems[h].push(f))}}return this.hasChanges=!0,this.expandItemsFromDelta(i).then(function(){new ye(n.apiRequestService,n.queryMatcherFactory,n,function(e){return n.collectionHandler.getAllCollectionsByItemType(e)}).processDelta(i).removeFromAndAddToCollections();for(var t=0,r=n.children;t<r.length;t++){var o=r[t];o!==e&&o.applyChangesFromParent(i)}return i.itemIdConversionMap})},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);return void 0!==t?t:this.parent.getLocalItemEntry(e)},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);return void 0!==r?r:this.parent.getLocalItemEntryByItemId(e,t)},t.prototype.getLocalCollectionEntry=function(e){var t=this.collectionHandler.entries.getByEntryId(e);return void 0!==t?t:this.parent.getLocalCollectionEntry(e)},t.prototype.getDelta=function(){var e=this.changesDeltaFactory.constructInternalDelta();for(var t in this.itemHandler.itemChanges){var r=this.getLocalItemEntryChangesTuple(Number(t));if(this.itemHandler.entries.contains(r.entry.itemType,r.entry.itemId)&&r.entry.isLocal())e.setItemCreated(r.entry,r.changes.changes);else{var n=this.getParent(r.entry);if(null!==n){var o=this.getParent(r.entry,!0);this.itemEntryService.matchParent(o,n)||e.setItemMoved(r.entry,n)}this.apiFormatter.hasChanges(r.changes.initial,r.changes.changes,r.entry.columns.main)&&e.setItemUpdated(r.entry,r.changes.changes)}}for(var i in this.itemHandler.deletedItems)e.setItemsDeleted(this.itemHandler.deletedItems[i]);return e},t.prototype.createItemResource=function(e,t,r,n){void 0===r&&(r=!1),r&&(this.rootItem=e),void 0===this.itemHandler.itemChanges[e.id]&&(this.itemHandler.itemChanges[e.id]={initial:this.getItemChangesRecursively(e.id),changes:this.getItemChangesRecursively(e.id)});var o=this.itemResourceFactory.construct(e,t,this,n);return this.itemHandler.addResource(o),o},t.prototype.createItemResources=function(e,t){for(var r=this.itemResourceFactory.getConstructor(t,this),n=[],o=0,i=e;o<i.length;o++){var s=i[o];void 0===this.itemHandler.itemChanges[s.id]&&(this.itemHandler.itemChanges[s.id]={initial:this.getItemChangesRecursively(s.id,!0),changes:this.getItemChangesRecursively(s.id,!0)});var a=r(s);n.push(a),this.itemHandler.addResource(a)}return n},t.prototype.processLinkedItems=function(e,t){var r={};for(var n in e)r[n]=this.createItemResources(e[n],t);return r},t.prototype.createCollectionResource=function(e,t){if(void 0===this.collectionHandler.collectionChanges[e.id]){this.collectionHandler.collectionChanges[e.id]=[];for(var r=new ye(this.apiRequestService,this.queryMatcherFactory,this,function(){return[e]}),n=0,o=this.getTransactionChain();n<o.length;n++)for(var i=0,s=o[n].itemHandler.entries.getByItemType(e.itemType);i<s.length;i++){var a=s[i],c=this.getItemChangesRecursively(a.id,!1);r.expand(a,c)}r.removeFromAndAddToCollections()}var u=this.collectionResourceFactory.construct(e,t,this);return this.collectionHandler.addResource(u),u},t.prototype.getChangesFromItemChanges=function(e){return e.changes},t.prototype.createCollectionResources=function(e,t){var r={};for(var n in e)r[n]=this.createCollectionResource(e[n],t);return r},t.prototype.expandItemsFromDelta=function(e){var t={},r={},n=function(e){void 0===t[e.itemType]&&(t[e.itemType]=[]),t[e.itemType].push(e)};for(var o in e.created)n(e.created[o].entry);for(var o in e.updated)n(e.updated[o].entry);for(var i in t){var s=this.collectionHandler.getAllCollectionsByItemType(i);if(0!==s.length){for(var a=this.requestColumnExpansionFactory.construct(),c=0,u=s;c<u.length;c++){var l=u[c];a.expand(l.columns)}r[i]=a.get()[i]}}var h=[];for(var i in r)h.push(this.itemHandler.expandLocalItemEntries(e,i,t[i],r[i],this.columnCache.retrieve(i,r[i]).cached));return this.promiseService.all(h)},t}(he);!function(e){e.MAYBE="maybe"}(ae||(ae={}));var Fe,Ee,Se=function(){function e(e,t){this.queryMatcherFactory=e,this.transaction=t,this.entries={}}return e.prototype.getByEntryId=function(e){for(var t in this.entries){var r=this.entries[t][e];if(void 0!==r)return r}},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.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],s=this.transaction.collectionHandler.collectionChanges[i.id];void 0!==s&&(s.some(function(e){return e.itemId==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 a=n[s],c=i.matchQuery(a.query.object);!0===c?o.fitting.push(a):c===ae.MAYBE?o.maybe.push(a):o.notfitting.push(a)}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||!(this.transaction instanceof Ie))return n;for(var o in r)for(var i=0,s=this.transaction.collectionHandler.collectionResources[o];i<s.length;i++){var a=s[i];a.options.resourceKey===t&&n.push(a)}return n},e}(),Re=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.createUnfoundLocalCollectionError=function(e){return{message:"A local collection of type "+e+" could not be found"}},e.prototype.cloneOptions=function(e,t){var r=new J(e);return r.queryParams=this.cloneQueryParams(e.queryParams),r.parent=t,r},e.prototype.processOptions=function(e){return new J(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=[]),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 a=0;a<e.length;a++)e[a]=r[a];return n},e}(),qe=function(){function e(){}return e.prototype.processOptions=function(e){return new K(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}(),Te=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 a=[];this.retrieveColumns(s.itemType,i.children,a,n),0!==a.length&&r.push(((o={})[i.id]=a,o))}}else r.push(t)},e.prototype.getColumn=function(e,t){var r=this.cache[e];if(void 0!==r)return r[t]},e}(),we=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[a(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.columnInfoFactory.constructFromRootMap(r)},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}(),be=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}(),He=">",Me=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+He+r,this.tailPath=0===t.level?r:t.tailPath+He+r)}return e.prototype.setChildren=function(e,t){return this.itemType=e,this.children=t,this.isLeaf=!1,this},e}(),xe={},ke=0,De=function(){function e(e,t,r){this.columnUtil=e,this.columnSetFactory=t,this.itemType=r,this.id=++ke,this.response=xe,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=[]}return e.prototype.groupColumnInfo=function(e){var t=this.columnUtil,r=e.apiColumn,n=null!==e.parent;n?this.derived.push(e):(this.main.push(e),"link"===r.type&&(this.link=e),this[t.isItemColumn(r)?"item":"notItem"].push(e),e.isLeaf||this.root.push(e)),t.isFormattedColumn(r)&&this.formatted[n?"derived":"main"].push(e),t.isFilteredColumn(r)&&this.filtered.push(e),t.isSearchableColumn(r)&&this.searchable.push(e),t.isCustomColumn(r)&&this.custom.push(e),e.isLeaf&&this.leaf.push(e)},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.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.getMergedColumnSet=function(e,t,r){var n=this.columnSetFactory.construct(this.itemType,e.merged,t);return n.requestColumnsTrue=this.requestColumnsTrue||r,n},e.prototype.mergeRequestColumns=function(e){return this.columnUtil.mergeRequestColumns(this.request,e)},e.prototype.mergeResponseColumns=function(e){return this.columnUtil.mergeResponseColumns(this.response,e).merged},e.prototype.merge=function(e){return this.getMergedColumnSet(this.mergeRequestColumns(e.request),this.mergeResponseColumns(e.response),e.requestColumnsTrue)},e.prototype.expand=function(e,t,r){var n=this.mergeRequestColumns(e),o=this.mergeResponseColumns(r);return{merged:this.getMergedColumnSet(n,o,t),difference:this.columnSetFactory.construct(this.itemType,n.difference,o,!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}(),Pe=function(){function e(e){this.linkTreeService=e}return e.prototype.getColumnsFromLink=function(e,t){var r=this.linkTreeService.get()[e][t],n=[];switch(r.type){case k.DIRECT:n.push(r.field);break;case k.ITEMTABLE:n.push("itemtype"),n.push("item")}return n},e.prototype.getColumnPath=function(e,t){for(var r="",n="",o=0,i=e;o<i.length;o++){n+=r+i[o].id,r=He}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=0,r=e;t<r.length;t++){var n=r[t];if(this.parseRequestColumn(n).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],a=this.parseRequestColumn(s),c=a.children,u=r[e];if(void 0===u)return!1;if(void 0===(i=u[a.id]))return!1;if(c.length>0&&!this.responseColumnsAvailable(i.itemType,c,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],a=this.mergeRequestColumn(s,r);null!==a&&n.push(a)}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=[],a=0,c=o.children;a<c.length;a++){var u=c[a],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)b(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(He)},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}(),_e=function(){function e(e,t,r,n,o,i){void 0===i&&(i=!1),this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r,this.compilation=n,this.transaction=o,this.breakupByParent=i,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.transaction.collectionHandler.getCollectionMatcher()}},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 a=e[i][s],c=a.entry,u=d(this.compilation,[i,c.itemId]),l=n.items[i][c.itemId]={},h=d(this.transaction.tabRequestParameters,[i,c.itemId]);if(null!==t&&(n.parentId[c.itemId]=t),r.columns.expand(c.columns),o[i][s]=c,l.values=this.apiFormatter.formatRequestLocal(a.fields,c.columns.main),l.parameters=h,void 0!==u){var p=l.links={};for(var f in u)for(var m in p[f]=[],u[f])p[f].push(parseInt(m,10));this.extendRequest(u,null,r)}}},e}();!function(e){e.OR="OR",e.AND="AND"}(Fe||(Fe={})),function(e){e.EQUALS="=",e.NOT_EQUALS="!=",e.LESS_THAN="<",e.MORE_THAN=">",e.LESS_OR_EQUAL_THAN="<=",e.EQUAL_OR_MORE_THAN=">=",e.IN="IN"}(Ee||(Ee={}));var je,Le,Ae=function(){function e(e){this.query=e}return 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.custom)return this.parseCustomQuery(e.custom,e.parameters,e.not);if(void 0!==e.search)return this.parseSearchQuery(e.search,e.not);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator,e.not);if(void 0!==e.itemType)return this.parseSubFieldQuery(e.key,e.itemType,e.field,e.query,e.not);if(void 0!==e.key)return"object"==typeof e.query?this.parseSubQuery(e.key,e.query,e.not):this.parseSimpleQuery(e.key,e.value,e.comparator,e.not);var t=a(e);if(null===t)return this.parseEmptyQuery();var r=e[t];return null!==r&&"object"==typeof r&&r.constructor===Object?this.parseSubQuery(t,r,!1):this.parseSimpleQuery(t,r,e.comparator,e.not)},e}(),Be=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)}}(),Qe=function(e){function t(t,r,n){var o=e.call(this,n)||this;return o.columnUtil=t,o.itemType=r,o}return Be(t,e),t.prototype.parseEmptyQuery=function(){return[]},t.prototype.parseSubQuery=function(e,t,r){var n;return void 0===r&&(r=!1),[(n={},n[e]=this.parse(t),n)]},t.prototype.parseSubFieldQuery=function(e,t,r,n,o){return[]},t.prototype.parseSearchQuery=function(e,t){return[]},t.prototype.parseCustomQuery=function(e,t,r){return void 0===r&&(r=!1),[]},t.prototype.parseSimpleQuery=function(e,t,r,n){return[e]},t.prototype.parseLinkedToQuery=function(e,t,r,n){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1),this.columnUtil.getColumnsFromLink(e,this.itemType)},t.prototype.parseComplexQuery=function(e,t,r){return this.parseConditions(e)},t.prototype.parseConditions=function(e){var t=this;return e.reduce(function(e,r){return e.concat(t.parse(r))},[])},t}(Ae),Ue=function(){function e(e,t,r,n,o){this.collectionEntryService=e,this.columnUtil=t,this.requestColumnExpansionFactory=r,this.transaction=o,this.collectionChanges={},this.entries=n.construct(this.transaction)}return e.prototype.createCollectionEntry=function(e,t){var r=this.transaction.core.collectionEntryFactory.construct(e,t);return this.entries.add(r),r},e.prototype._addItemEntriesToCollectionChanges=function(e,t,r,n){if(0!==t.length){var o=this.collectionChanges[e.id];if(void 0!==o){for(var i=[],s=0,a=t;s<a.length;s++){var c=a[s];-1!==o.indexOf(c)||r(c)||(o.push(c),i.push(c))}return this.handleAddedItemEntriesCallback(e,i,n)}}},e.prototype.removeItemEntriesFromCollectionChanges=function(e,t,r){if(void 0===r&&(r=!1),0===t.length)return[];var n=this.collectionChanges[e.id];if(void 0!==n){var o=this.collectionEntryService.filterArray(n,function(e){return!c(e.itemId,t)});return this.handleRemovedItemEntriesCallback(e,o,r)}},e.prototype.expandColumnsWithQueryColumns=function(e,t,r){var n=new Qe(this.columnUtil,e,r);if(t.queryColumns=n.parse(),!0!==t.columns){var o=this.requestColumnExpansionFactory.construct();o.expandWithRequestColumns(e,t.columns),o.expandWithRequestColumns(e,t.queryColumns),t.columns=o.get()[e]}},e}(),Ve=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(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f){var m=e.call(this,a,d,n,s,f)||this;return m.columnSubsetCacheFactory=t,m.requestBufferManager=r,m.columnExpansionFactory=o,m.apiRequestService=i,m.collectionMatcherFactory=c,m.errorHandler=u,m.itemHandler=l,m.promiseService=h,m.queryService=p,m.transaction=f,m}return Ve(t,e),t.prototype.getCollectionMatcher=function(){var e=this;return this.collectionMatcherFactory.construct(this.transaction,function(t){return e.entries.getByItemType(t)})},t.prototype.fetchCollectionEntry=function(e,t){var r=this.collectionEntryService.createQuery(t);this.expandColumnsWithQueryColumns(e,t,r.object);var n=this.columnSubsetCacheFactory.construct(t.columns);return this.fetchCollectionData(e,n,t,r)},t.prototype.fetchLinkedCollectionEntries=function(e,t,r,n){var o={};S(t)&&(t=t());for(var i=0,s=t;i<s.length;i++){var a=s[i],c=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:a}),u=this.collectionEntryService.createQuery(c);this.expandColumnsWithQueryColumns(r,c,u.object);var l=this.columnSubsetCacheFactory.construct(c.columns);o[a]=this.fetchCollectionData(r,l,c,u)}return this.promiseService.all(o)},t.prototype.extendCollectionEntry=function(e,t){var r,n,o=e.extendQuery(t).object,i=this.queryService.addAndCondition(o,this.queryService.createNotIn(this.collectionChanges[e.id].map(function(e){return e.itemId})));return this.expandColumnsWithQueryColumns(e.itemType,e.options,o),n=null!==e.options.limit?this.apiRequestService.requestSkeleton({requestType:"query",itemType:e.itemType,columns:(r={},r[e.itemType]=e.options.columns,r),query:o,limit:e.options.limit}):this.requestBufferManager.fetchByQuery(e.itemType,i,e.options.columns),e.promise=n,n.then(function(){delete e.promise},this.errorHandler.reject),n.then(function(){return e})},t.prototype.expandCollectionEntries=function(e,t,r,n){var o=this;if(0===n.length)return this.promiseService.when(r);var i=[];for(var s in r){var a=r[s].entry;i.push(a.parent.itemId)}return this.itemHandler.fetchLinkedItemEntriesData(e,i,t,null,n).then(function(e){for(var s=o.columnExpansionFactory.construct(t,n,e.fetchColumnsObject()),a=0,c=i;a<c.length;a++){var u=c[a];r[u].entry.expandColumns(s)}return r})},t.prototype.extendCollectionEntries=function(e,t,r,n,o){if(!s(o))return this.promiseService.when();var i=[],a=[];for(var c in r.queryParams=n(r.queryParams),o){var u=o[c].entry;u.extendQuery(n),i.push(u.parent.itemId),a=a.concat(this.collectionChanges[u.id].map(function(e){return e.itemId}))}return this.itemHandler.fetchLinkedItemEntriesData(e,i,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(a)),r.columns).then(function(){},this.errorHandler.reject)},t.prototype.addItemEntriesToCollectionChanges=function(t,r,n){void 0===n&&(n=!1),e.prototype._addItemEntriesToCollectionChanges.call(this,t,r,function(e){return e.isLocal()},n)},t.prototype.expandCollectionEntry=function(e,t){var r=this,n=e.columns.mergeRequestColumns(t),o=n.merged,i=n.difference;if(!0!==i&&0===i.length)return this.promiseService.when(e);var s=e.itemType;return(null!==e.options.limit?this.apiRequestService.requestSkeleton({requestType:"query",itemType:s,columns:o,query:e.query.object,limit:e.options.limit}):this.requestBufferManager.fetchByQuery(e.itemType,[e.query.object,e.query.string],o)).then(function(t){var n=r.columnExpansionFactory.construct(s,o,t.fetchColumnsObject());return e.expandColumns(n),n},this.errorHandler.reject)},t.prototype.handleAddedItemEntriesCallback=function(e,t){t.length},t.prototype.handleRemovedItemEntriesCallback=function(e,t){t.length},t.prototype.fetchCollectionData=function(e,t,r,n){var o,i=this,s=this.entries.getByQuery(e,n);return null!==s&&t.run(s.columns)?this.promiseService.when(s):(null!==r.limit?this.apiRequestService.requestSkeleton({requestType:"query",itemType:e,columns:(o={},o[e]=r.columns,o),query:r.query,limit:r.limit}).then(function(e){return i.transaction.processResponse(e,!1,!1),e},this.errorHandler.reject):this.requestBufferManager.fetchByQuery(e,[n.object,n.string],t.requestColumns)).then(function(o){if(null===(s=i.entries.getByQuery(e,n)))(s=i.createCollectionEntry(e,r)).columns=i.transaction.core.columnSetFactory.constructFromResponse(e,o.fetchColumnsObject());else{var a=i.columnExpansionFactory.construct(e,t.requestColumns,o.fetchColumnsObject());s.expandColumns(a)}return s})},t}(Ue),We=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)}}(),Ye=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p){var d=e.call(this,a,c,u,s,i,h,l,p)||this;return d.requestBufferManager=t,d.queryParserFactory=r,d.queryService=n,d.columnSubsetCacheFactory=o,d.transaction=p,d.itemChanges={},d}return We(t,e),t.prototype.createItemEntry=function(t){var r=e.prototype.createItemEntry.call(this,t);return this.itemChanges[r.id]=t.fields,r},t.prototype.processItemEntryChanges=function(e,t,r,n){var o=e.entry,i=e.changes;void 0===this.itemChanges[o.id]&&(this.itemChanges[o.id]={}),null!==i.expandedColumns&&(o.columns=i.expandedColumns.merged);var s=this.apiFormatter.copyFields(this.itemChanges[o.id],{},o.columns.main);return this.apiFormatter.copyFields(i.fields,this.itemChanges[o.id],o.columns.main),void 0!==i.fields.id&&(o.itemId=i.fields.id),s},t.prototype.copyTransactionItemEntryChanges=function(e,t){return this.apiFormatter.copyFields(e.changes,{},t.columns.main)},t.prototype.fetchItemEntry=function(e,t,r){var n=this;return r.columns=this.expandColumnsWithCollectionColumns(e,r.columns),this.fetchItemEntryData(e,t,this.columnSubsetCacheFactory.construct(r.columns)).then(function(){return n.entries.get(e,t)},this.errorHandler.reject)},t.prototype.fetchItemEntriesByQuery=function(e,t,r){var n=this;return r.columns=this.expandColumnsWithCollectionColumns(e,r.columns),this.requestBufferManager.fetchByQuery(e,this.queryParserFactory.construct(this.queryService.addParentCondition(t,r.parent)).parse(),r.columns).then(function(t){for(var r=[],o=0,i=t.links[e];o<i.length;o++){var s=i[o],a=n.entries.get(e,s);void 0!==a&&r.push(a)}return r},this.errorHandler.reject)},t.prototype.fetchItemEntries=function(e,t,r){var n=this;r.columns=this.expandColumnsWithCollectionColumns(e,r.columns);for(var o=this.columnSubsetCacheFactory.construct(r.columns),i=[],s=0,a=t;s<a.length;s++){var c=a[s];i.push(this.fetchItemEntryData(e,c,o))}return this.promiseService.all(i).then(function(){for(var r=[],o=0,i=t;o<i.length;o++){var s=i[o];r.push(n.entries.get(e,s))}return r},this.errorHandler.reject)},t.prototype.fetchLinkedItemEntriesData=function(e,t,r,n,o){return null===n?this.requestBufferManager.fetchByIds(e,t,o):this.requestBufferManager.fetchByQuery(r,this.queryParserFactory.construct(this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}})).parse(),o)},t.prototype.processApiResponse=function(e,t,r,n,o,i){var s=this.entries.get(r,n),a=t.fetchObject(r,n);if(void 0===a)throw new Error("Fields not found in response for "+r+":"+n);void 0===s?e.setItemCreated(n,a,o):e.setItemUpdated(s,a,i.run(s.columns))},t.prototype.fetchItemEntryData=function(e,t,r){var n=this.entries.get(e,t);return void 0!==n&&r.run(n.columns)?this.promiseService.when():this.requestBufferManager.fetchById(e,t,r.requestColumns).then(function(){},this.errorHandler.reject)},t}(ce),Je=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)}}(),Ke=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D,O){var P=e.call(this,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,I,F,E,S,R,q,T,w,b,H,M,x,k,D,C,O)||this;return P.changesProcessorFactory=t,P.parent=null,P.itemHandler=new Ye(o,k,D,R,y,g,q,C,T,f,i,P),P.collectionHandler=new Ne(R,o,i,F,I,m,M,x,y,P.itemHandler,g,D,q,P),P}return Je(t,e),t.prototype.getServerCache=function(){return this},t.prototype.processResponse=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r=!1);var n=this.core.changesDeltaFactory.construct(),o=e.fetchColumnsObject();for(var i in e.items){var s=this.core.columnSetFactory.constructFromResponse(i,o),a=this.core.columnExpansionFactory.construct(i,s.request,o);for(var c in e.items[i])this.itemHandler.processApiResponse(n,e,i,Number(c),s,a)}return this.applyChangesDelta(n,t,r)},t.prototype.applyChangesFromParent=function(e,t,r){var n=this;for(var o in void 0===t&&(t=!1),void 0===r&&(r=!1),e.updated)this.itemHandler.processItemEntryChanges(e.updated[o],r);for(var i in e.deleted)for(var s=0,a=e.deleted[i];s<a.length;s++){var c=a[s];this.itemHandler.entries.clear(c),delete this.itemHandler.itemChanges[c.id]}new ye(this.apiRequestService,this.queryMatcherFactory,this,function(e){return n.collectionHandler.entries.getByItemType(e)}).processDelta(e).removeFromAndAddToCollections(r);for(var u=0,l=this.children;u<l.length;u++){l[u].applyChangesFromParent(e,t,r)}},t.prototype.getLinkFieldsByParent=function(e,t){var r=this.linkTreeService.get()[e.itemType][t],n={};if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");return r.type===k.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},t.prototype.getParent=function(e,t,r){return this.getParentFromFields(e,this.itemHandler.itemChanges[e.id])},t.prototype.getItemChangesRecursively=function(e,t){void 0===t&&(t=!0);var r=this.itemHandler.itemChanges[e],n=this.getLocalItemEntry(e);if(void 0!==r&&void 0!==n)return t?this.apiFormatter.copyFields(r,{},n.columns.main):r;if(void 0===n)throw new Error("No local entry found");throw new Error("No local fields found for ItemEntry with ItemType '"+n.itemType+"'")},t.prototype.getLocalItemEntryChangesTuple=function(e){var t=this.getLocalItemEntry(e);if(void 0===t)throw new Error("Tried to get a local ItemEntry with entryId '"+e+"' but couldn't find it");return{entry:t,changes:this.itemHandler.itemChanges[e]}},t.prototype.getCollectionChangesRecursively=function(e){var t=this.getLocalCollectionEntry(e),r=this.collectionHandler.collectionChanges[e];if(void 0!==t)return void 0===r&&(r=this.collectionHandler.collectionChanges[e]=[]),r.slice();throw new Error("No local collection items found")},t.prototype.invalidateCache=function(){this.itemHandler.entries.forEach(function(e){return e.queueReload()}),this.collectionHandler.entries.forEach(function(e){return e.queueReload()})},t.prototype.applyChangesFromChild=function(e,t,r){return this.changesProcessorFactory.construct(e,t,r).execute()},t.prototype.applyChangesDelta=function(t,r,n){var o=this;return void 0===r&&(r=!0),void 0===n&&(n=!1),0!==t.created.length||s(t.updated)||s(t.deleted)?this.fetchUpdatedDerivedValuesFromDelta(t).then(function(){var i=e.prototype._applyChangesDelta.call(o,t),s=i.result,a=i.internalChangesDelta,c=i.rollbackFunctions;for(var u in t.deleted)for(var l=function(e){o.itemHandler.entries.clear(e);var r=o.itemHandler.itemChanges[e.id];delete t.updated[e.id],delete o.itemHandler.itemChanges[e.id],a.setItemDeleted(e),c.push(function(t){t.setItemUpdated(e,r)})},h=0,p=t.deleted[u];h<p.length;h++){l(p[h])}new ye(o.apiRequestService,o.queryMatcherFactory,o,function(e){return o.collectionHandler.entries.getByItemType(e)}).processDelta(a).removeFromAndAddToCollections(n);for(var d=0,f=o.children;d<f.length;d++){f[d].applyChangesFromParent(a,r,n)}return s}):this.promiseService.when({created:[],rollback:Nt})},t.prototype.getLocalItemEntry=function(e){var t=this.itemHandler.entries.getByEntryId(e);if(void 0!==t)return t},t.prototype.getLocalItemEntryByItemId=function(e,t){var r=this.itemHandler.entries.get(e,t);if(void 0!==r)return r},t.prototype.getLocalCollectionEntry=function(e){var t=this.collectionHandler.entries.getByEntryId(e);if(void 0!==t)return t},t.prototype.getChangesFromItemChanges=function(e){return e},t}(he),ze=function(){function e(e,t){this.queryMatcherFactory=e,this.transaction=t,this.entries={},this.entriesByEntryId={}}return e.prototype.getByEntryId=function(e){return this.entriesByEntryId[e]},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];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],a=this.transaction.getParent(s);null!==a&&(a.itemType===e&&a.itemId==t&&o.push(s))}return o},e.prototype.batchGetLocalByParent=function(e,t,r,n){for(var o=this.entries[r],i={},s=0,a=t;s<a.length;s++){i[a[s]]=[]}if(void 0===o)return i;for(var c in o){var u=o[c],l=this.transaction.getParent(u);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]={}),this.entriesByEntryId[e.id]=e,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={},this.entriesByEntryId={},!0):this.clearByItemId(e.itemType,e.itemId)},e.prototype.clearByItemId=function(e,t){var r=this.entries[e];return void 0!==r&&(delete this.entriesByEntryId[r[t].id],delete r[t])},e.prototype.matchQuery=function(e,t){var r=this.transaction.getLocalItemEntryChangesTuple(e.id);return!0===this.queryMatcherFactory.construct(e.itemType,this.transaction instanceof Ke?r.changes:r.changes.changes,this.transaction.getParent(e)).matchQuery(t.object)},e}(),Xe=function(){function e(e,t,r){this.authInterface=e,this.keyService=t,this.linkTreeService=r}return e.prototype.matchParent=function(e,t){return null===e&&null===t||!(null===e&&null!==t||null!==e&&null===t)&&(e.itemType===t.itemType&&e.itemId==t.itemId)},e.prototype.getLinkFieldsByParent=function(e,t){var r=this.linkTreeService.get()[e.itemType][t];if(void 0===r)throw new Error("Non existing link between '"+e.itemType+"'->'"+t+"'");var n={};return r.type===k.DIRECT?n[r.field]=e.itemId:(n.itemtype=e.itemType,n.item=e.itemId),n},e.prototype.getParentByFields=function(e,t,r){var n=this.linkTreeService.get()[e][t.itemType];if(void 0===n)throw new Error("Non existing link between '"+e+"'->'"+t.itemType+"'");var o={};return n.type===k.DIRECT?(o.itemType=e,o.itemId=r[n.field]):(o.itemType=r.itemtype,o.itemId=r.item),o},e.prototype.getDisplayName=function(e,t){switch(e.itemType){case"Contact":return"bedrijf"===t.type?t.bedrijf:this.getFullName(t.voornaam,t.tussenvoegsel,t.naam);case"Medewerker":case"Person":return this.getFullName(t.voornaam,t.tussenvoegsel,t.achternaam);default:return t[this.getTitleField(e.itemType)]}},e.prototype.processOptions=function(e){return new L(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.createExistingLocalItemError=function(e){return{message:"A local item of type "+e+" not be created, the ID is already in use"}},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 a=0,c=s;a<c.length;a++){var u=c[a];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.getFullName=function(e,t,r){return void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),e.trim().concat(" ",t).trim().concat(" ",r).trim()},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}(),Ge=function(){function e(){this.separator=":"}return e.prototype.getSingleKey=function(e,t){return e+this.separator+t},e.prototype.getCssKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.join("_")},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}(),Ze=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.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){var t=this.lockItems;for(var r in t)for(var n in t[r]){var o=t[r][n];if(!o.isForeign&&o.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,r=this.errorHandler;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},r.reject).then(function(e){return e.isForeign?r.reject(e.message):e.token},r.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=this.lockItems[e.itemType];return void 0!==t&&delete t[e.itemId]},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}(),$e={},et=function(){function e(e){this.transaction=e,this.parentMap={},this.destination={}}return e.prototype.process=function(){if(void 0===this.transaction.rootItem)throw new Error("A TransactionCache rootItem is required for ModuleChangesCompilation");return this.parentMap=this.createParentMap(),this.processItems(this.transaction.rootItem.itemType,[this.transaction.rootItem],{}),{itemType:this.transaction.rootItem.itemType,itemId:this.transaction.rootItem.itemId,items:this.destination}},e.prototype.createParentMap=function(){var e=this,t={};return this.transaction.itemHandler.entries.forEach(function(r){var n=r.itemType,o=e.transaction.getParent(r);if(null!==o){var i=o.itemType,s=o.itemId;void 0===t[i]&&(t[i]={}),void 0===t[i][s]&&(t[i][s]={}),void 0===t[i][s][n]&&(t[i][s][n]=[]),t[i][s][n].push(r)}}),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.transaction.collectionHandler.entries.getCollectionsByParent(t,r),i=this.transaction.itemHandler.formatRequest(e),a={};for(var c in n)this.processItems(c,n[c],a);for(var u=0,l=o;u<l.length;u++){var h=l[u];null===h.options.query&&this.processItems(h.itemType,this.transaction.collectionHandler.collectionChanges[h.id],a)}var p=s(i),d=s(a);return p&&d?{values:i,links:a}:p?{values:i}:d?{links:a}:$e},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),tt="maybe",rt=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 tt;if(void 0!==e.custom)return tt;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.query)return tt;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 tt;var t,r=this.parent;return(t=null!==r&&(e.linkedTo===r.itemType&&this.matchSimpleQuery(r.itemId,e.query)))===tt?tt: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],a=this.matchQuery(s);if(a===r)return e.not?!r:r;a===tt&&(t=tt)}return t===tt?tt:e.not?!t: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),tt;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":var i=c(e,o);return t.not?!i:i;default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}(),nt=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){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(Le||(Le={}));var ot=Object.keys(Ee).map(function(e){return Ee[e]}),it=((je={})[Ee.EQUALS]=Ee.NOT_EQUALS,je[Ee.NOT_EQUALS]=Ee.EQUALS,je[Ee.MORE_THAN]=Ee.LESS_OR_EQUAL_THAN,je[Ee.LESS_THAN]=Ee.EQUAL_OR_MORE_THAN,je[Ee.LESS_OR_EQUAL_THAN]=Ee.MORE_THAN,je[Ee.EQUAL_OR_MORE_THAN]=Ee.LESS_THAN,je[Ee.IN]=Ee.IN,je),st=function(e){function t(t,r){var n=e.call(this,t)||this;return n.parameters=r,n}return nt(t,e),t.prototype.parseEmptyQuery=function(){return[{},"{}"]},t.prototype.parseSubQuery=function(e,t,r){void 0===r&&(r=!1);var n=this.parse(t);return[{key:e,query:n[Le.OBJ],not:r},"[sub"+Le.SEP+e+Le.SEP+n[Le.STR]+Le.SEP+r+"]"]},t.prototype.parseSubFieldQuery=function(e,t,r,n,o){void 0===e&&(e=""),void 0===t&&(t=""),void 0===r&&(r=""),void 0===o&&(o=!1);var i=this.parse(n);return[{key:e,itemType:t,field:r,query:i[Le.OBJ],not:o},"[subField"+Le.SEP+e+Le.SEP+t+Le.SEP+r+Le.SEP+i[Le.STR]+Le.SEP+o+"]"]},t.prototype.parseSearchQuery=function(e,t){return void 0===t&&(t=!1),[{search:(e=this.formatValue(e))[Le.OBJ],not:t},"[search"+Le.SEP+e[Le.STR]+Le.SEP+t+"]"]},t.prototype.parseCustomQuery=function(e,t,r){if(void 0===r&&(r=!1),void 0===t)return[{custom:e,not:r},"["+e+Le.SEP+r+"]"];var n=this.parseCustomParameters(t);return[{custom:e,parameters:n[Le.OBJ],not:r},"["+e+Le.SEP+n[Le.STR]+Le.SEP+r+"]"]},t.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[Le.OBJ],o>0&&(n+=Le.SEP),n+=s[Le.STR]}return[r,n]},t.prototype.parseSimpleQuery=function(e,t,r,n){if(void 0===n&&(n=!1),t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[Le.OBJ])?Ee.IN:Ee.EQUALS),-1===ot.indexOf(r))throw new Error("Unknown comparator '"+r+"', it might be that the backend supports it but the frontend doesn't !");n&&(r=it[r]);var o=r===Ee.IN&&n,i=[{key:e,value:t[Le.OBJ],comparator:r,not:o},"["+r+Le.SEP+e+Le.SEP+t[Le.STR]+"]"];return o&&(i[1]=i[1].slice(0,-1),i[1]+=Le.SEP+n+"]"),i},t.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[Le.OBJ],reverse:r,not:n},"[linkedTo"+Le.SEP+e+Le.SEP+o[Le.STR]+Le.SEP+r+Le.SEP+n+"]"]},t.prototype.parseComplexQuery=function(e,t,r){void 0===t&&(t=Fe.AND),void 0===r&&(r=!1),t=t.toUpperCase();var n=this.parseConditions(e);return[{conditions:n[Le.OBJ],operator:t,not:r},"["+t+n[Le.STR]+Le.SEP+r+"]"]},t.prototype.parseConditions=function(e){for(var t=this,r=[],n=[],o="",i=0,s=e;i<s.length;i++){var a=s[i];r.push(this.parse(a))}for(var c=0,u=r=r.sort(function(e,r){return t.compareParsedQueries(e,r)});c<u.length;c++){var l=u[c];n.push(l[Le.OBJ]),o+=l[Le.STR]}return[n,o]},t.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]},t.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():n.isMoment(e)?n(e):n.isDuration(e)?n.duration(e):e},t.prototype.compareParsedQueries=function(e,t){return e[Le.STR]===t[Le.STR]?0:e[Le.STR]>t[Le.STR]?1:-1},t}(Ae),at=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||e.operator===Fe.OR?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return e.operator===Fe.OR?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:Fe.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:Ee.IN,key:"id",value:e,not:!0}},e}(),ct=function(){function e(e){this.columnUtil=e,this.columns={},this.columnSetIdMap={}}return e.prototype.expandWithRequestColumns=function(e,t){var r=this.columns;void 0===r[e]&&(r[e]=[]),r[e]=this.columnUtil.mergeRequestColumns(r[e],t).merged},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}(),ut=function(){function e(e,t,r,n,o,i,s,a){this.requestBufferManager=e,this.changesDeltaFactory=t,this.apiFormatter=r,this.errorHandler=n,this.transactionCacheFactory=o,this.promiseService=i,this.requestColumnExpansionFactory=s,this.apiRequestService=a}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)}},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=this.transactionCacheFactory.getServerCache(),o={};for(var i in t){var s=t[i],a=null!==s.parent?s.parent:{},c=this.formatMessageValues(s.values,r);o[i]=n.collectionHandler.entries.getByFittingItem(e,c,a)}return o},e.prototype.getRequestColumns=function(e,t){var r=this.transactionCacheFactory.getServerCache(),n=this.requestColumnExpansionFactory.construct();for(var o in t){for(var i=t[o].fitting,s=r.itemHandler.entries.get(e,o),a=0,c=i;a<c.length;a++){var u=c[a];n.expand(u.columns)}void 0!==s&&n.expand(s.columns)}return n.get()},e.prototype.processMessage=function(e){var t=this.transactionCacheFactory.getServerCache(),r=e.itemType,n=[],o=this.createCollectionMap(r,e.items[r],e.columns[r]),i=this.getRequestColumns(r,o);for(var s in o){var a=+s;void 0===t.itemHandler.entries.get(r,s)?0!==o[a].fitting.length&&n.push(a):n.push(a)}return 0===n.length?this.promiseService.when():this.apiRequestService.query(r,{key:"id",comparator:"IN",value:n},i).then(function(e){return t.processResponse(e,!1,!0)},this.errorHandler.reject)},e.prototype.processFunctionChangesResolve=function(e){var t=this,r=this.transactionCacheFactory.getServerCache(),n=e.items.FunctionChangesResolve,o=[];for(var i in n){var s=n[i].parent.itemId,a=r.itemHandler.entries.get("Functie",s);void 0!==a&&void 0!==a.columns.response.Functie.newchanges&&o.push(s)}return 0===o.length?this.promiseService.when():this.requestBufferManager.fetchByIds("Functie",o,["newchanges"]).then(function(e){for(var n=t.changesDeltaFactory.construct(),o=0,i=e.response.links.Functie;o<i.length;o++){var s=i[o],a=r.itemHandler.entries.get("Functie",s),c=r.itemHandler.itemChanges[a.id],u=e.response.fetchObject("Functie",s,!1);void 0!==u&&u.newchanges!==c.newchanges&&n.setItemUpdated(a,{newchanges:u.newchanges})}return r.applyChangesDelta(n,!1,!0)},this.errorHandler.reject).catch(this.errorHandler.notifyError)},e.prototype.isFunctionChangesResolveMessage=function(e){return"FunctionChangesResolve"===e.body.itemType},e.prototype.handleCreate=function(e){var t=e.body;return this.isFunctionChangesResolveMessage(e)?this.processFunctionChangesResolve(t):this.processMessage(t).catch(this.errorHandler.notifyError)},e.prototype.handleUpdate=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e.prototype.handleDelete=function(e){for(var t=this.changesDeltaFactory.constructInternalDelta(),r=this.transactionCacheFactory.getServerCache(),n=e.body,o=[],i=0,s=n.items;i<s.length;i++){var a=s[i],c=r.itemHandler.entries.get(n.itemType,a);void 0!==c&&o.push(c)}return t.setItemsDeleted(o),r.applyChangesFromParent(t,!1,!0),this.promiseService.when()},e.prototype.handleLinkMove=function(e){return this.processMessage(e.body).catch(this.errorHandler.notifyError)},e}(),lt=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)}}(),ht=function(){return(ht=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},pt=function(e){function t(t,r,n,o,i,s,a,c,u,l,h,p,d,f,m){var y=e.call(this,a,r,t,s,m)||this;return y.columnSubsetCacheFactory=n,y.columnExpansionFactory=o,y.changesDeltaFactory=i,y.collectionMatcherFactory=c,y.columnHandler=u,y.errorHandler=l,y.itemHandler=h,y.keyService=p,y.promiseService=d,y.exceptionHandler=f,y.transaction=m,y.collectionResources={},y}return lt(t,e),t.prototype.getAllCollectionsByItemType=function(e){var t=[];for(var r in this.collectionChanges){var n=this.transaction.getLocalCollectionEntry(Number(r));void 0!==n&&n.itemType===e&&t.push(n)}return t},t.prototype.createCollectionEntry=function(t,r){return this.isLocal(r)?e.prototype.createCollectionEntry.call(this,t,r):this.transaction.getServerCache().collectionHandler.createCollectionEntry(t,r)},t.prototype.onItemEntriesCreated=function(e,t){var r=this.collectionResources[e.id];if(void 0!==r)for(var n=0,o=r;n<o.length;n++){var i=o[n];try{i.options.onItemsCreated(t)}catch(e){this.exceptionHandler(e)}}},t.prototype.clearEntry=function(e){this.entries.clear(e),delete this.collectionResources[e.id],delete this.collectionChanges[e.id]},t.prototype.addResource=function(e){var t=this.collectionResources[e.entry.id];void 0===t&&(t=this.collectionResources[e.entry.id]=[]),t.push(e)},t.prototype.clearResource=function(e){var t=this.collectionResources[e.entry.id],r=t.indexOf(e);-1!==r&&t.splice(r,1),0===t.length&&delete this.collectionResources[e.entry.id]},t.prototype.moveItems=function(e,t,r){if(e.itemType!==t.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var n=this.changesDeltaFactory.construct(),o=0,i=r;o<i.length;o++){var s=i[o];n.setItemMoved(s,t.parent)}this.transaction.applyChangesDelta(n)},t.prototype.extendCollectionEntry=function(e,t){return this.transaction.getServerCache().collectionHandler.extendCollectionEntry(e,t)},t.prototype.cloneCollectionEntry=function(e,t,r){void 0===r&&(r={});var n=this.collectionChanges[e.id],o=this.createCollectionEntry(e.itemType,this.collectionEntryService.cloneOptions(e.options,t));if(null!==e.parent){var i=e.parent;void 0===r[i.itemType]&&(r[i.itemType]={}),r[i.itemType][i.itemId]=t.itemId}return this.itemHandler.cloneItemEntries(n,r),o},t.prototype.getCollectionMatcher=function(){var e=this;return this.collectionMatcherFactory.construct(this.transaction,function(t){return e.getAllCollectionsByItemType(t)})},t.prototype.fetchCollectionEntry=function(e,t){var r=this;if(!this.isLocal(t))return this.transaction.getServerCache().collectionHandler.fetchCollectionEntry(e,t);var n,o=this.changesDeltaFactory.construct(),i=this.columnSubsetCacheFactory.construct(t.columns),s=this.collectionEntryService.createQuery(t);return this.expandColumnsWithQueryColumns(e,t,s.object),this.fetchCollectionData(o,e,i,t,s).then(function(e){return n=e,r.transaction.applyChangesDelta(o)},this.errorHandler.reject).then(function(){return n},this.errorHandler.reject)},t.prototype.fetchLinkedCollectionEntries=function(e,t,r,n){S(t)&&(t=t());for(var o=[],i=[],s=0,a=t;s<a.length;s++){var c=a[s];this.keyService.isLocalId(c)?i.push(c):o.push(c)}return this.promiseService.all({remote:this.transaction.getServerCache().collectionHandler.fetchLinkedCollectionEntries(e,o,r,n),local:this.fetchLinkedLocalCollectionEntries(e,i,r,n)}).then(function(e){return ht({},e.remote,e.local)})},t.prototype.expandCollectionEntries=function(e,t,r,n){return this.transaction.getServerCache().collectionHandler.expandCollectionEntries(e,t,r,n)},t.prototype.extendCollectionEntries=function(e,t,r,n,o){return this.transaction.getServerCache().collectionHandler.extendCollectionEntries(e,t,r,n,o)},t.prototype.addItemEntriesToCollectionChanges=function(t,r,n){void 0===n&&(n=!1),e.prototype._addItemEntriesToCollectionChanges.call(this,t,r,function(){return!1},n)},t.prototype.isLocal=function(e){var t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)},t.prototype.expandCollectionEntry=function(e,t,r){var n=this,o=t.columns.mergeRequestColumns(r).difference;if(!0!==o&&0===o.length)return this.promiseService.when(t);var i=t.itemType;return this.columnHandler.fetch(i,o).then(function(r){return n.itemHandler.expandLocalItemEntries(e,i,n.collectionChanges[t.id],o,r).then(function(){var e=n.columnExpansionFactory.construct(i,o,r);return t.expandColumns(e),t},n.errorHandler.reject)},this.errorHandler.reject)},t.prototype.handleAddedItemEntriesCallback=function(e,t){var r=this.collectionResources[e.id];if(0!==t.length&&void 0!==r&&0!==r.length)for(var n=0,o=r;n<o.length;n++){o[n].addItemResources(t)}},t.prototype.handleRemovedItemEntriesCallback=function(e,t){var r=this.collectionResources[e.id];if(0!==t.length&&void 0!==r&&0!==r.length)for(var n=0,o=r;n<o.length;n++){var i=o[n],s=i.removeItemResources(t);i.callOnRemove(s)}},t.prototype.fetchCollectionData=function(e,t,r,n,o){var i=this.entries.getByQuery(t,o);return null!==i?r.run(i.columns)?this.promiseService.when(i):this.expandCollectionEntry(e,i,r.requestColumns):this.promiseService.when(this.createCollectionEntry(t,n))},t.prototype.fetchLinkedLocalCollectionEntries=function(e,t,r,n){for(var o=this,i=this.changesDeltaFactory.construct(),s=this.columnSubsetCacheFactory.construct(n.columns),a={},c=0,u=t;c<u.length;c++){var l=u[c],h=this.collectionEntryService.cloneOptions(n,{itemType:e,itemId:l}),p=this.collectionEntryService.createQuery(h);this.expandColumnsWithQueryColumns(r,h,p.object),a[l]=this.fetchCollectionData(i,r,s,h,p)}return this.promiseService.all(a).then(function(e){return o.transaction.applyChangesDelta(i).then(function(){return e},o.errorHandler.reject)},this.errorHandler.reject)},t}(Ue),dt=function(){function e(e){this.itemEntryService=e,this.updated={},this.deleted={}}return e.prototype.setItemUpdated=function(e,t,r,n){void 0===r&&(r=null),void 0===n&&(n=null),void 0===this.updated[e.id]&&(this.updated[e.id]={entry:e,changes:{fields:{},expandedColumns:null,parent:n}});var o=this.updated[e.id];if(null!==n){var i=this.itemEntryService.getLinkFieldsByParent(n,e.itemType);for(var s in i)t[s]=i[s]}for(var a in t){var c=Object.getOwnPropertyDescriptor(t,a);void 0!==c?Object.defineProperty(o.changes.fields,a,c):o.changes.fields[a]=t[a]}null!==r&&(o.changes.expandedColumns=r)},e.prototype.setItemDeleted=function(e){this.setItemsDeleted([e])},e.prototype.setItemsDeleted=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];void 0===this.deleted[n.itemType]&&(this.deleted[n.itemType]=[]),this.deleted[n.itemType].indexOf(n)>-1||this.deleted[n.itemType].push(n)}},e}(),ft=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)}}(),mt=function(e){function t(t){var r=e.call(this,t)||this;return r.created=[],r}return ft(t,e),t.prototype.setItemCreated=function(e,t,r,n){void 0===n&&(n=null);var o={};if(null!==n)for(var i in o=this.itemEntryService.getLinkFieldsByParent(n,r.itemType))t[i]=o[i];var s=this.itemEntryService.getLocalDefaultValues();for(var i in s)t[i]=s[i];this.created.push({itemId:e,fields:t,columns:r})},t.prototype.setItemMoved=function(e,t){this.setItemUpdated(e,{},null,t)},t}(dt),yt=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)}}(),vt=function(e){function t(t){var r=e.call(this,t)||this;return r.created={},r.moved={},r.itemIdConversionMap={},r}return yt(t,e),t.prototype.setItemCreated=function(e,t){this.created[e.id]={entry:e,fields:t}},t.prototype.setItemMoved=function(e,t){this.moved[e.id]={entry:e,to:t}},t}(dt),gt=function(){function e(e,t,r,n,o){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.serverCache=n,this.itemType=o,this.deferred=this.promiseLibrary.defer(),this.requestColumnExpansion=this.requestColumnExpansionFactory.construct(),this.singleItemIds=[],this.queries={}}return e.prototype.containsId=function(e){return-1!==this.singleItemIds.indexOf(e)},e.prototype.containsQuery=function(e){return void 0!==this.queries[e]},e.prototype.addSingleItem=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),-1===this.singleItemIds.indexOf(e)&&this.singleItemIds.push(e),this.getPromise()},e.prototype.addQuery=function(e,t){return this.requestColumnExpansion.expandWithRequestColumns(this.itemType,t),void 0===this.queries[e[1]]&&(this.queries[e[1]]=e[0]),this.getPromise()},e.prototype.flush=function(){var e=this,t=[];for(var r in this.singleItemIds.length>0&&t.push({key:"id",comparator:"IN",value:this.singleItemIds}),this.queries)t.push(this.queries[r]);if(0===t.length)throw new Error("Tried to flush a RequestBuffer without singleItems or queries");var n=this.requestColumnExpansion.get();return this.apiRequestService.query(this.itemType,{conditions:t,operator:"OR"},n).then(function(t){e.serverCache.processResponse(t,!1,!1),e.deferred.resolve(t)},function(t){e.deferred.reject(t)}),this.getPromise()},e.prototype.getPromise=function(){return this.deferred.promise},e}(),Ct=function(){function e(e,t,r,n,o){this.promiseLibrary=e,this.apiRequestService=t,this.requestColumnExpansionFactory=r,this.keyService=n,this.errorHandler=o,this.pendingBufferMap={},this.pendingTrueBufferMap={},this.pendingQueryBufferMap={},this.pendingTemplateBufferMap={}}return e.prototype.setServerCache=function(e){this.serverCache=e},e.prototype.containsId=function(e,t){return!!d(this.pendingTemplateBufferMap,[e,t])||void 0!==this.pendingBufferMap[e]&&this.pendingBufferMap[e].containsId(t)},e.prototype.containsQuery=function(e,t){return void 0!==d(this.pendingQueryBufferMap,[e,t])},e.prototype.fetchByIds=function(e,t,r){for(var n=0,o=t;n<o.length;n++){var i=o[n];this.fetchById(e,i,r)}return this.pendingBufferMap[e].getPromise()},e.prototype.fetchById=function(e,t,r){if(this.keyService.isLocalId(t))throw new Error("Unexpected local ItemId in RequestBufferManager.fetchById, for local ItemIds you should use RequestBufferManager.fetchByLocalId");var n;return!0===r?void 0===(n=this.pendingTrueBufferMap[e])?n=this.constructBuffer(e,this.pendingTrueBufferMap):console.log("Existing 'columns: true' RequestBuffer "+e+" at "+performance.now()+" by id"):void 0===(n=this.pendingBufferMap[e])?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" by id"),n.addSingleItem(t,r),n.getPromise()},e.prototype.fetchByQuery=function(e,t,r){var n=this.pendingBufferMap[e];return void 0===n?n=this.constructBuffer(e):console.log("Existing RequestBuffer "+e+" at "+performance.now()+" with query"),n.addQuery(t,r),n.getPromise()},e.prototype.fetchByLocalId=function(e,t,r){return void 0===t&&(t="no-id"),void 0===this.pendingTemplateBufferMap[e]||void 0===this.pendingTemplateBufferMap[e][t]?this.constructTemplateBuffer(e,t,r):this.pendingTemplateBufferMap[e][t]},e.prototype.constructBuffer=function(e,t){void 0===t&&(t=this.pendingBufferMap);var r=t[e]=new gt(this.promiseLibrary,this.apiRequestService,this.requestColumnExpansionFactory,this.serverCache,e);return window.setTimeout(function(){r.flush(),delete t[e]},150),r},e.prototype.constructTemplateBuffer=function(e,t,r){var n=this;return void 0===this.pendingTemplateBufferMap[e]&&(this.pendingTemplateBufferMap[e]={}),this.pendingTemplateBufferMap[e][t]=this.apiRequestService.template(e,r).then(function(r){return delete n.pendingTemplateBufferMap[e][t],r},function(){return delete n.pendingTemplateBufferMap[e][t],n.errorHandler.reject()})},e}(),It=function(){function e(e,t,r,n,o,i,s){this.columnUtil=e,this.promiseService=t,this.requestBufferFactory=r,this.columnHandler=n,this.templateFactory=o,this.errorHandler=i,this.requestColumnExpansionFactory=s,this.templates={}}return e.prototype.fetchTemplate=function(e,t,r,n,o){var i=this;void 0===r&&(r={}),void 0===n&&(n={}),void 0===o&&(o=null);var a=s(r),c=this.requestColumnExpansionFactory.construct();if(void 0!==n[e]&&c.expandWithRequestColumns(e,n[e]),c.expandWithRequestColumns(e,[{creator:["displayname"]},"created","permissions"]),null!==o&&c.expandWithRequestColumns(e,this.columnUtil.getColumnsFromLink("string"==typeof o?o:o.itemType,e)),n[e]=c.get()[e],!a){var u=this.templates[e];if(void 0!==u&&(null===e||this.columnUtil.responseColumnsAvailable(e,n[e],u.responseColumns)))return this.promiseService.when(u)}return this.promiseService.all({template:this.requestBufferFactory.fetchByLocalId(e,t,r),additionalColumns:void 0===n[e]?{}:this.columnHandler.fetch(e,n[e])}).then(function(t){var r=t.template,o=i.templateFactory.construct(e,r,n,t.additionalColumns);return!a&&r.cacheable&&(i.templates[e]=o),o},this.errorHandler.reject)},e}(),Ft=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e){return new P(this.apiFormatter,e)},e}(),Et=function(){function e(){}return e.prototype.construct=function(e){return new _(e)},e}(),St=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e){return new Se(this.queryMatcherFactory,e)},e}(),Rt=function(){function e(e,t,r){this.collectionEntryService=e,this.columnSetFactory=t,this.keyService=r}return e.prototype.construct=function(e,t){return new X(this.collectionEntryService,this.columnSetFactory,this.keyService,e,new J(t))},e}(),qt=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e,t){return new fe(this.queryMatcherFactory,e,t)},e}(),Tt=function(){function e(e,t,r,n,o,i){this.errorHandler=e,this.exceptionHandler=t,this.itemResourceFactory=r,this.keyService=n,this.promiseService=o,this.changesDeltaFactory=i}return e.prototype.construct=function(e,t,r){var n=new K(t);return n.editCollection?new te(this,e,n,r):new $(this,e,n,r)},e}(),wt=function(){function e(e){this.columnInfoFactory=e}return e.prototype.construct=function(e,t,r){return new we(this.columnInfoFactory,e,t,r)},e}(),bt=function(){function e(){}return e.prototype.construct=function(e,t){return new Me(e,t)},e.prototype.constructFromRootMap=function(e,t){void 0===t&&(t=null);var r=[];for(var n in e){var o=e[n],i=this.construct(o.apiColumn,t),s=this.constructFromRootMap(o.children,i);s.length>0&&i.setChildren(i.apiColumn.itemType,s),r.push(i)}return r},e}(),Ht=function(){function e(e,t,r){this.columnHandler=e,this.columnUtil=t,this.columnInfoFactory=r}return e.prototype.constructStub=function(e,t){var r=new De(this.columnUtil,this,e);return r.request=t,r.requestColumnsTrue=!0===t,r},e.prototype.resolveStub=function(e,t,r,n){return void 0===r&&(r=!0),void 0===n&&(n=!0),e.requestColumnsTrue?this.processResponseColumns(e,t,r):this.processRequestColumns(e,t,r,n)},e.prototype.construct=function(e,t,r,n,o){return this.resolveStub(this.constructStub(e,t),r,n,o)},e.prototype.constructFromResponse=function(e,t,r){void 0===r&&(r=!0);var n=new De(this.columnUtil,this,e);return n.requestColumnsTrue=!1,this.processResponseColumns(n,t,r)},e.prototype.processResponseColumns=function(e,t,r){var n=e.itemType,o={};return e.response=t,this.expandRootColumnMapFromResponseColumns(n,t,o,r,{}),this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(o),n),e.request=this.constructRequestColumnsFromRootColumnMap(o),e},e.prototype.constructRequestColumnsFromRootColumnMap=function(e){var t,r=[];for(var n in e){var o=e[n];s(o.children)?r.push(((t={})[n]=this.constructRequestColumnsFromRootColumnMap(o.children),t)):r.push(n)}return r},e.prototype.expandRootColumnMapFromResponseColumns=function(e,t,r,n,o){if(!0!==o[e])for(var i in o[e]=!0,t[e]){var a=t[e][i];if(void 0!==a&&(n&&this.columnHandler.setColumn(e,a),void 0===r[i]&&(r[i]={apiColumn:a,children:{}}),this.columnUtil.isItemColumn(a,!1))){var c=t[a.itemType];void 0!==c&&s(c)&&this.expandRootColumnMapFromResponseColumns(a.itemType,t,r[i].children,n,o)}}},e.prototype.processRequestColumns=function(e,t,r,n){var o=e.itemType,i={};return this.expandRootColumnMap(e.request,o,t,i,r),n&&this.expandRootColumnMap(["id"],o,t,i,r),e.response={},this.processColumnInfo(e,this.columnInfoFactory.constructFromRootMap(i),o),e},e.prototype.processColumnInfo=function(e,t,r){var n=e.response;void 0===n[r]&&(n[r]={});for(var o=0,i=t;o<i.length;o++){var s=i[o];n[r][s.id]=s.apiColumn,e.groupColumnInfo(s),s.isLeaf||this.processColumnInfo(e,s.children,s.itemType)}},e.prototype.expandRootColumnMap=function(e,t,r,n,o){for(var i=0,s=e;i<s.length;i++){var a=s[i],c=this.columnUtil.parseRequestColumn(a),u=c.id,l=c.children,h=void 0;void 0!==r[t]&&(h=r[t][u]),void 0!==h?(o&&(h=this.columnHandler.setColumn(t,h)),void 0===n[u]&&(n[u]={apiColumn:h,children:{}}),0!==l.length&&this.expandRootColumnMap(l,h.itemType,r,n[u].children,o)):console.warn("No api column for request column",u,"for itemType",t)}},e}(),Mt=function(){function e(){}return e.prototype.construct=function(e){return new Oe(e)},e}(),xt=function(){function e(e,t,r){this.apiFormatter=e,this.keyService=t,this.requestColumnExpansionFactory=r}return e.prototype.construct=function(e,t,r){return new _e(this.apiFormatter,this.keyService,this.requestColumnExpansionFactory,e,t,r)},e}(),kt=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(e){return new ze(this.queryMatcherFactory,e)},e}(),Dt=function(){function e(e,t,r,n,o,i,s,a){this.authInterface=e,this.apiFormatter=t,this.columnSetFactory=r,this.exceptionHandler=n,this.itemEntryService=o,this.itemResourceFactory=i,this.keyService=s,this.promiseService=a}return e.prototype.construct=function(e,t){return new Q(this,t.itemType,e,t)},e}(),Ot=function(){function e(e,t,r,n,o,i,s){this.apiFormatter=e,this.lockService=t,this.errorHandler=r,this.promiseService=n,this.exceptionHandler=o,this.columnUtil=i,this.linkTreeService=s}return e.prototype.getConstructor=function(e,t){var r=this,n=new A(e);return function(e){return r.constructWithOptions(e,n,t)}},e.prototype.construct=function(e,t,r,n){return this.constructWithOptions(e,new A(t),r,n)},e.prototype.constructWithOptions=function(e,t,r,n){return void 0===n&&(n=!1),t.edit?new Y(this,e,t,n,r):t.remote?new oe(this,e,t,n,r):new se(this,e,t,n,r)},e}(),Pt=function(){function e(e,t,r,n,o,i,s,a,c,u,l,h,p,d,f,m,y,v,g,C,I,F,E,S,R,q,T,w,b,H,M,x,k,D){this.core=e,this.columnCache=t,this.requestBufferManager=r,this.requestColumnExpansionFactory=n,this.queryMatcherFactory=o,this.authInterface=i,this.changesDeltaFactory=s,this.changesProcessorFactory=a,this.lockService=c,this.moduleChangesCompilationFactory=u,this.collectionResourceFactory=l,this.itemResourceFactory=h,this.templateCache=p,this.itemCacheFactory=d,this.collectionCacheFactory=f,this.errorHandler=m,this.exceptionHandler=y,this.promiseService=v,this.apiFormatter=g,this.apiRequestService=C,this.columnExpansionFactory=I,this.columnHandler=F,this.columnSetFactory=E,this.columnSubsetCacheFactory=S,this.columnUtil=R,this.itemEntryFactory=q,this.itemEntryService=T,this.keyService=w,this.collectionEntryFactory=b,this.collectionEntryService=H,this.collectionMatcherFactory=M,this.queryParserFactory=x,this.queryService=k,this.linkTreeService=D,this.serverCache=new Ke(this.changesProcessorFactory,this.core,this.columnCache,this.requestBufferManager,this.requestColumnExpansionFactory,this.queryMatcherFactory,this.authInterface,this.changesDeltaFactory,this.lockService,this.moduleChangesCompilationFactory,this.collectionResourceFactory,this.itemResourceFactory,this.templateCache,this.itemCacheFactory,this.collectionCacheFactory,this.errorHandler,this.exceptionHandler,this.promiseService,this.apiFormatter,this.apiRequestService,this.columnExpansionFactory,this.columnHandler,this.columnSetFactory,this.columnSubsetCacheFactory,this.columnUtil,this.itemEntryFactory,this.itemEntryService,this.keyService,this.collectionEntryFactory,this.collectionEntryService,this.collectionMatcherFactory,this.queryParserFactory,this.queryService,this.linkTreeService)}return e.prototype.getById=function(e){var t=function(r){for(var n=0,o=r;n<o.length;n++){var i=o[n];if(i.id===e)return i;var s=t(i.children);if(void 0!==s)return s}};return t(this.serverCache.children)},e.prototype.construct=function(e){return this.serverCache.createChild(e)},e.prototype.getServerCache=function(){return this.serverCache},e}(),_t=function(){function e(){}return e.prototype.construct=function(e){return new et(e)},e}(),jt=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r){return new rt(this.apiFormatter,e,t,r)},e}(),Lt=function(){function e(){}return e.prototype.construct=function(e,t){return new st(e,t)},e}(),At=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new ct(this.columnUtil)},e}(),Bt=function(){function e(e,t){this.columnSetFactory=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r,n){return new re(this,e,t,r,n)},e}(),Qt=function(){function e(e){this.itemEntryService=e}return e.prototype.construct=function(){return new mt(this.itemEntryService)},e.prototype.constructInternalDelta=function(){return new vt(this.itemEntryService)},e}(),Ut=function(){function e(e,t,r,n,o,i,s,a,c,u){this.changesDeltaFactory=e,this.apiRequestService=t,this.changesCompilationFactory=r,this.columnExpansionFactory=n,this.createRequestFactory=o,this.errorHandler=i,this.promiseService=s,this.requestColumnExpansionFactory=a,this.collectionEntryService=c,this.itemEntryService=u}return e.prototype.construct=function(e,t,r){return new j(this.changesDeltaFactory,this.apiRequestService,this.changesCompilationFactory,this.columnExpansionFactory,this.createRequestFactory,this.errorHandler,this.promiseService,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,e,t,r)},e}(),Vt=function(){return function(e,t,r,n,o,i){this.version="2.0.12",this.noop=Nt;var s=new Ge,a=new Xe(t,s,i),c=new Qt(a),u=new D,l=new Ft(u),h=new O(e,l),p=new jt(u),d=new Lt,f=new at,m=new Pe(i),y=new Te(m),v=new be(h,r,o,y,m),g=new bt,C=new wt(g),I=new Ht(v,m,g),F=new Mt,E=new Ze(h,r,s,o),S=new Bt(I,m),R=new kt(p),q=new Ot(u,E,r,o,n,m,i),T=new Tt(r,n,q,s,o,c),w=new Dt(t,u,I,n,a,q,s,o),b=new Re(d,f),H=new qe,M=new Rt(b,I,s),x=new St(p),k=new qt(p),P=new At(m),_=new xt(u,s,P),j=new Et,L=new Ut(c,h,j,C,_,r,o,P,b,a),A=new _t,B=new Ct(o,h,P,s,r),Q=new It(m,o,B,v,S,r,P),U=new Pt(this,y,B,P,p,t,c,L,E,A,T,q,Q,R,x,r,n,o,u,h,C,v,I,F,m,w,a,s,M,b,k,d,f,i);B.setServerCache(U.getServerCache());var V=new ut(B,c,u,r,U,o,P,h);this.apiFormatter=u,this.apiRequestService=h,this.apiResponseProcessorFactory=l,this.changesCompilationFactory=j,this.changesProcessorFactory=L,this.collectionCacheFactory=x,this.collectionEntryFactory=M,this.collectionEntryService=b,this.collectionMatcherFactory=k,this.collectionResourceFactory=T,this.collectionResourceService=H,this.columnCache=y,this.columnExpansionFactory=C,this.columnHandler=v,this.columnInfoFactory=g,this.columnSetFactory=I,this.columnSubsetCacheFactory=F,this.columnUtil=m,this.createRequestFactory=_,this.itemCacheFactory=R,this.itemEntryFactory=w,this.itemEntryService=a,this.itemResourceFactory=q,this.keyService=s,this.transactionCacheFactory=U,this.lockService=E,this.moduleChangesCompilationFactory=A,this.queryMatcherFactory=p,this.queryParserFactory=d,this.queryService=f,this.requestColumnExpansionFactory=P,this.socketMessageHandler=V,this.templateFactory=S,this.changesDeltaFactory=c,this.templateCache=Q}}();function Nt(){}function Wt(e){return e}r.d(t,"RmCore",function(){return Vt}),r.d(t,"noop",function(){return Nt}),r.d(t,"identity",function(){return Wt}),r.d(t,"ALL_PERMISSIONS",function(){return"7"}),r.d(t,"COLUMN_SEPERATOR",function(){return He}),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,"ItemEntryOptions",function(){return L}),r.d(t,"ItemResourceOptions",function(){return A}),r.d(t,"ItemEntry",function(){return Q}),r.d(t,"ItemResource",function(){return U}),r.d(t,"ViewResource",function(){return N}),r.d(t,"EditResource",function(){return Y}),r.d(t,"CollectionEntryOptions",function(){return J}),r.d(t,"CollectionResourceOptions",function(){return K}),r.d(t,"CollectionEntry",function(){return X}),r.d(t,"CollectionResource",function(){return G}),r.d(t,"CollectionViewResource",function(){return $}),r.d(t,"CollectionEditResource",function(){return te}),r.d(t,"Template",function(){return re}),r.d(t,"RemoteViewResource",function(){return oe}),r.d(t,"LocalViewResource",function(){return se}),r.d(t,"ApiFormatter",function(){return D}),r.d(t,"ApiRequestService",function(){return O}),r.d(t,"ApiResponseProcessor",function(){return P}),r.d(t,"ChangesCompilation",function(){return _}),r.d(t,"ChangesProcessor",function(){return j}),r.d(t,"CollectionCache",function(){return Se}),r.d(t,"CollectionEntryService",function(){return Re}),r.d(t,"CollectionMatcher",function(){return fe}),r.d(t,"CollectionResourceService",function(){return qe}),r.d(t,"ColumnCache",function(){return Te}),r.d(t,"ColumnExpansion",function(){return we}),r.d(t,"ColumnHandler",function(){return be}),r.d(t,"ColumnInfo",function(){return Me}),r.d(t,"ColumnSet",function(){return De}),r.d(t,"ColumnSubsetCache",function(){return Oe}),r.d(t,"ColumnUtil",function(){return Pe}),r.d(t,"CreateRequest",function(){return _e}),r.d(t,"ItemCache",function(){return ze}),r.d(t,"ItemEntryService",function(){return Xe}),r.d(t,"KeyService",function(){return Ge}),r.d(t,"TransactionEventHandler",function(){return ve}),r.d(t,"LockService",function(){return Ze}),r.d(t,"ModuleChangesCompilation",function(){return et}),r.d(t,"QueryMatcher",function(){return rt}),r.d(t,"CONSTANTS",function(){return Le}),r.d(t,"QueryParser",function(){return st}),r.d(t,"QueryService",function(){return at}),r.d(t,"RequestColumnExpansion",function(){return ct}),r.d(t,"SocketMessageHandler",function(){return ut}),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 a}),r.d(t,"inArray",function(){return c}),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 d}),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 F}),r.d(t,"isArray",function(){return E}),r.d(t,"isFunction",function(){return S}),r.d(t,"isRegExp",function(){return R}),r.d(t,"isBoolean",function(){return q}),r.d(t,"isElement",function(){return T}),r.d(t,"isWindow",function(){return w}),r.d(t,"isDefined",function(){return b}),r.d(t,"equals",function(){return H}),r.d(t,"copy",function(){return M}),r.d(t,"AbstractCache",function(){return he}),r.d(t,"ServerCache",function(){return Ke}),r.d(t,"ServerItemHandler",function(){return Ye}),r.d(t,"ServerCollectionHandler",function(){return Ne}),r.d(t,"TransactionCache",function(){return Ie}),r.d(t,"TransactionItemHandler",function(){return le}),r.d(t,"TransactionCollectionHandler",function(){return pt}),r.d(t,"ChangesDelta",function(){return mt}),r.d(t,"InternalChangesDelta",function(){return vt}),r.d(t,"RequestBufferManager",function(){return Ct}),r.d(t,"RequestBuffer",function(){return gt}),r.d(t,"ApiResponseProcessorFactory",function(){return Ft}),r.d(t,"ChangesCompilationFactory",function(){return Et}),r.d(t,"CollectionCacheFactory",function(){return St}),r.d(t,"CollectionEntryFactory",function(){return Rt}),r.d(t,"CollectionMatcherFactory",function(){return qt}),r.d(t,"CollectionResourceFactory",function(){return Tt}),r.d(t,"ColumnExpansionFactory",function(){return wt}),r.d(t,"ColumnInfoFactory",function(){return bt}),r.d(t,"ColumnSetFactory",function(){return Ht}),r.d(t,"ColumnSubsetCacheFactory",function(){return Mt}),r.d(t,"CreateRequestFactory",function(){return xt}),r.d(t,"ItemCacheFactory",function(){return kt}),r.d(t,"ItemEntryFactory",function(){return Dt}),r.d(t,"ItemResourceFactory",function(){return Ot}),r.d(t,"TransactionCacheFactory",function(){return Pt}),r.d(t,"ModuleChangesCompilationFactory",function(){return _t}),r.d(t,"QueryMatcherFactory",function(){return jt}),r.d(t,"QueryParserFactory",function(){return Lt}),r.d(t,"RequestColumnExpansionFactory",function(){return At}),r.d(t,"TemplateFactory",function(){return Bt}),r.d(t,"ChangesDeltaFactory",function(){return Qt}),r.d(t,"ChangesProcessorFactory",function(){return Ut}),r.d(t,"ApiLinkTreeType",function(){return k})}])});