@rentman/rm-core 1.0.1 → 1.0.3

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 (65) hide show
  1. package/dist/definitions/{classes → src/classes}/BatchStatus.d.ts +1 -1
  2. package/dist/definitions/{classes → src/classes}/ChangesProcessor.d.ts +1 -1
  3. package/dist/definitions/{classes → src/classes}/CollectionHandler.d.ts +2 -2
  4. package/dist/definitions/{classes → src/classes}/ColumnHandler.d.ts +2 -2
  5. package/dist/definitions/{classes → src/classes}/ItemAdministrator.d.ts +3 -3
  6. package/dist/definitions/{classes → src/classes}/ItemHandler.d.ts +1 -1
  7. package/dist/definitions/{classes → src/classes}/ItemRequestService.d.ts +1 -1
  8. package/dist/definitions/src/classes/PromiseService.d.ts +9 -0
  9. package/dist/definitions/{classes → src/classes}/ResourceCache.d.ts +1 -1
  10. package/dist/definitions/{models → src/models}/CollectionEditResource.d.ts +3 -3
  11. package/dist/rm-core.js +2 -2
  12. package/dist/rm-core.js.map +1 -1
  13. package/package.json +1 -1
  14. package/dist/definitions/classes/PromiseService.d.ts +0 -10
  15. /package/dist/definitions/{classes → src/classes}/ApiFormatter.d.ts +0 -0
  16. /package/dist/definitions/{classes → src/classes}/ChangesCompiler.d.ts +0 -0
  17. /package/dist/definitions/{classes → src/classes}/CollectionCache.d.ts +0 -0
  18. /package/dist/definitions/{classes → src/classes}/CollectionEntryService.d.ts +0 -0
  19. /package/dist/definitions/{classes → src/classes}/CollectionResourceService.d.ts +0 -0
  20. /package/dist/definitions/{classes → src/classes}/ColumnCache.d.ts +0 -0
  21. /package/dist/definitions/{classes → src/classes}/ColumnExpansion.d.ts +0 -0
  22. /package/dist/definitions/{classes → src/classes}/ColumnSet.d.ts +0 -0
  23. /package/dist/definitions/{classes → src/classes}/ColumnUtil.d.ts +0 -0
  24. /package/dist/definitions/{classes → src/classes}/CreateRequest.d.ts +0 -0
  25. /package/dist/definitions/{classes → src/classes}/ItemCache.d.ts +0 -0
  26. /package/dist/definitions/{classes → src/classes}/ItemEntryService.d.ts +0 -0
  27. /package/dist/definitions/{classes → src/classes}/ItemResourceService.d.ts +0 -0
  28. /package/dist/definitions/{classes → src/classes}/KeyService.d.ts +0 -0
  29. /package/dist/definitions/{classes → src/classes}/LockService.d.ts +0 -0
  30. /package/dist/definitions/{classes → src/classes}/ModuleChangesCompiler.d.ts +0 -0
  31. /package/dist/definitions/{classes → src/classes}/QueryMatcher.d.ts +0 -0
  32. /package/dist/definitions/{classes → src/classes}/QueryParser.d.ts +0 -0
  33. /package/dist/definitions/{classes → src/classes}/QueryService.d.ts +0 -0
  34. /package/dist/definitions/{classes → src/classes}/RequestColumnExpansion.d.ts +0 -0
  35. /package/dist/definitions/{classes → src/classes}/Util.d.ts +0 -0
  36. /package/dist/definitions/{constants.d.ts → src/constants.d.ts} +0 -0
  37. /package/dist/definitions/{factories → src/factories}/BatchStatusFactory.d.ts +0 -0
  38. /package/dist/definitions/{factories → src/factories}/ChangesCompilerFactory.d.ts +0 -0
  39. /package/dist/definitions/{factories → src/factories}/ChangesProcessorFactory.d.ts +0 -0
  40. /package/dist/definitions/{factories → src/factories}/CollectionCacheFactory.d.ts +0 -0
  41. /package/dist/definitions/{factories → src/factories}/CollectionEntryFactory.d.ts +0 -0
  42. /package/dist/definitions/{factories → src/factories}/CollectionResourceFactory.d.ts +0 -0
  43. /package/dist/definitions/{factories → src/factories}/ColumnExpansionFactory.d.ts +0 -0
  44. /package/dist/definitions/{factories → src/factories}/ColumnSetFactory.d.ts +0 -0
  45. /package/dist/definitions/{factories → src/factories}/CreateRequestFactory.d.ts +0 -0
  46. /package/dist/definitions/{factories → src/factories}/ItemCacheFactory.d.ts +0 -0
  47. /package/dist/definitions/{factories → src/factories}/ItemEntryFactory.d.ts +0 -0
  48. /package/dist/definitions/{factories → src/factories}/ItemResourceFactory.d.ts +0 -0
  49. /package/dist/definitions/{factories → src/factories}/ModuleChangesCompilerFactory.d.ts +0 -0
  50. /package/dist/definitions/{factories → src/factories}/QueryMatcherFactory.d.ts +0 -0
  51. /package/dist/definitions/{factories → src/factories}/QueryParserFactory.d.ts +0 -0
  52. /package/dist/definitions/{factories → src/factories}/RequestColumnExpansionFactory.d.ts +0 -0
  53. /package/dist/definitions/{factories → src/factories}/ResourceCacheFactory.d.ts +0 -0
  54. /package/dist/definitions/{index.d.ts → src/index.d.ts} +0 -0
  55. /package/dist/definitions/{interfaces → src/interfaces}/ApiRequestServiceInterface.d.ts +0 -0
  56. /package/dist/definitions/{interfaces → src/interfaces}/AuthInterface.d.ts +0 -0
  57. /package/dist/definitions/{interfaces → src/interfaces}/ErrorHandlerInterface.d.ts +0 -0
  58. /package/dist/definitions/{interfaces → src/interfaces}/ResourceCacheInterface.d.ts +0 -0
  59. /package/dist/definitions/{models → src/models}/CollectionEntry.d.ts +0 -0
  60. /package/dist/definitions/{models → src/models}/CollectionResource.d.ts +0 -0
  61. /package/dist/definitions/{models → src/models}/CollectionViewResource.d.ts +0 -0
  62. /package/dist/definitions/{models → src/models}/EditResource.d.ts +0 -0
  63. /package/dist/definitions/{models → src/models}/ItemEntry.d.ts +0 -0
  64. /package/dist/definitions/{models → src/models}/ItemResource.d.ts +0 -0
  65. /package/dist/definitions/{models → src/models}/ViewResource.d.ts +0 -0
package/dist/rm-core.js CHANGED
@@ -1,4 +1,4 @@
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 i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=4)}([function(t,r){t.exports=e},function(e,t,r){(function(t,r){
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(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},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=4)}([function(t,r){t.exports=e},function(e,t,r){(function(t,r){
2
2
  /*!
3
3
  *
4
4
  * Copyright 2009-2017 Kris Kowal under the terms of the MIT
@@ -25,5 +25,5 @@
25
25
  * limitations under the License.
26
26
  *
27
27
  */
28
- !function(t){"use strict";"function"==typeof bootstrap?bootstrap("promise",t):e.exports=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var n,i=R(),o=function(){},s=function(){var e={task:void 0,next:null},n=e,i=!1,o=void 0,c=!1,a=[];function u(){for(var t,r;e.next;)t=(e=e.next).task,e.task=void 0,(r=e.domain)&&(e.domain=void 0,r.enter()),l(t,r);for(;a.length;)l(t=a.pop());i=!1}function l(e,t){try{e()}catch(e){if(c)throw t&&t.exit(),setTimeout(u,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}if(s=function(e){n=n.next={task:e,domain:c&&t.domain,next:null},i||(i=!0,o())},"object"==typeof t&&"[object process]"===t.toString()&&t.nextTick)c=!0,o=function(){t.nextTick(u)};else if("function"==typeof r)o="undefined"!=typeof window?r.bind(window,u):function(){r(u)};else if("undefined"!=typeof MessageChannel){var h=new MessageChannel;h.port1.onmessage=function(){o=p,h.port1.onmessage=u,u()};var p=function(){h.port2.postMessage(0)};o=function(){setTimeout(u,0),p()}}else o=function(){setTimeout(u,0)};return s.runAfter=function(e){a.push(e),i||(i=!0,o())},s}(),c=Function.call;function a(e){return function(){return c.apply(e,arguments)}}var u,l=a(Array.prototype.slice),h=a(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r<n;r++)r in this&&(t=e(t,this[r],r));return t}),p=a(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),f=a(Array.prototype.map||function(e,t){var r=this,n=[];return h(r,function(i,o,s){n.push(e.call(t,o,s,r))},void 0),n}),d=Object.create||function(e){function t(){}return t.prototype=e,new t},m=Object.defineProperty||function(e,t,r){return e[t]=r.value,e},v=a(Object.prototype.hasOwnProperty),y=Object.keys||function(e){var t=[];for(var r in e)v(e,r)&&t.push(r);return t},g=a(Object.prototype.toString);u="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var S="From previous event:";function C(t,r){if(e&&r.stack&&"object"==typeof t&&null!==t&&t.stack){for(var n=[],i=r;i;i=i.source)i.stack&&(!t.__minimumStackCounter__||t.__minimumStackCounter__>i.stackCounter)&&(m(t,"__minimumStackCounter__",{value:i.stackCounter,configurable:!0}),n.unshift(i.stack));n.unshift(t.stack);var o=function(e){for(var t=e.split("\n"),r=[],n=0;n<t.length;++n){var i=t[n];!E(i)&&-1===(o=i).indexOf("(module.js:")&&-1===o.indexOf("(node.js:")&&i&&r.push(i)}var o;return r.join("\n")}(n.join("\n"+S+"\n"));m(t,"stack",{value:o,configurable:!0})}}function I(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var r=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(r)return[r[1],Number(r[2])];var n=/.*@(.+):(\d+)$/.exec(e);return n?[n[1],Number(n[2])]:void 0}function E(e){var t=I(e);if(!t)return!1;var r=t[0],o=t[1];return r===n&&o>=i&&o<=J}function R(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),r=I(t[0].indexOf("@")>0?t[1]:t[2]);if(!r)return;return n=r[0],r[1]}}function q(e){return e instanceof w?e:x(e)?(t=e,r=b(),q.nextTick(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):B(e);var t,r}q.resolve=q,q.nextTick=s,q.longStackSupport=!1;var T=1;function b(){var t,r=[],n=[],i=d(b.prototype),o=d(w.prototype);if(o.promiseDispatch=function(e,i,o){var s=l(arguments);r?(r.push(s),"when"===i&&o[1]&&n.push(o[1])):q.nextTick(function(){t.promiseDispatch.apply(t,s)})},o.valueOf=function(){if(r)return o;var e=j(t);return H(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},q.longStackSupport&&e)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1),o.stackCounter=T++}function s(i){t=i,q.longStackSupport&&e&&(o.source=i),h(r,function(e,t){q.nextTick(function(){i.promiseDispatch.apply(i,t)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||s(q(e))},i.fulfill=function(e){t||s(B(e))},i.reject=function(e){t||s(V(e))},i.notify=function(e){t||h(n,function(t,r){q.nextTick(function(){r(e)})},void 0)},i}function F(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=b();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function k(e){return F(function(t,r){for(var n=0,i=e.length;n<i;n++)q(e[n]).then(t,r)})}function w(e,t,r){void 0===t&&(t=function(e){return V(new Error("Promise does not support operation: "+e))}),void 0===r&&(r=function(){return{state:"unknown"}});var n=d(w.prototype);if(n.promiseDispatch=function(r,i,o){var s;try{s=e[i]?e[i].apply(n,o):t.call(n,i,o)}catch(e){s=V(e)}r&&r(s)},n.inspect=r,r){var i=r();"rejected"===i.state&&(n.exception=i.reason),n.valueOf=function(){var e=r();return"pending"===e.state||"rejected"===e.state?n:e.value}}return n}function O(e,t,r,n){return q(e).then(t,r,n)}function j(e){if(H(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function H(e){return e instanceof w}function x(e){return(t=e)===Object(t)&&"function"==typeof e.then;var t}"object"==typeof t&&t&&t.env&&t.env.Q_DEBUG&&(q.longStackSupport=!0),q.defer=b,b.prototype.makeNodeResolver=function(){var e=this;return function(t,r){t?e.reject(t):arguments.length>2?e.resolve(l(arguments,1)):e.resolve(r)}},q.Promise=F,q.promise=F,F.race=k,F.all=W,F.reject=V,F.resolve=q,q.passByCopy=function(e){return e},w.prototype.passByCopy=function(){return this},q.join=function(e,t){return q(e).join(t)},w.prototype.join=function(e){return q([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Q can't join: not the same: "+e+" "+t)})},q.race=k,w.prototype.race=function(){return this.then(q.race)},q.makePromise=w,w.prototype.toString=function(){return"[object Promise]"},w.prototype.then=function(e,t,r){var n=this,i=b(),o=!1;return q.nextTick(function(){n.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return V(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){C(e,n);try{return t(e)}catch(e){return V(e)}}return V(e)}(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=function(e){return"function"==typeof r?r(e):e}(e)}catch(e){if(n=!0,!q.onerror)throw e;q.onerror(e)}n||i.notify(t)}]),i.promise},q.tap=function(e,t){return q(e).tap(t)},w.prototype.tap=function(e){return e=q(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},q.when=O,w.prototype.thenResolve=function(e){return this.then(function(){return e})},q.thenResolve=function(e,t){return q(e).thenResolve(t)},w.prototype.thenReject=function(e){return this.then(function(){throw e})},q.thenReject=function(e,t){return q(e).thenReject(t)},q.nearer=j,q.isPromise=H,q.isPromiseAlike=x,q.isPending=function(e){return H(e)&&"pending"===e.inspect().state},w.prototype.isPending=function(){return"pending"===this.inspect().state},q.isFulfilled=function(e){return!H(e)||"fulfilled"===e.inspect().state},w.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},q.isRejected=function(e){return H(e)&&"rejected"===e.inspect().state},w.prototype.isRejected=function(){return"rejected"===this.inspect().state};var M,D,P,A=[],L=[],_=[],U=!0;function N(){A.length=0,L.length=0,U||(U=!0)}function V(e){var r=w({when:function(r){return r&&function(e){if(U){var r=p(L,e);-1!==r&&("object"==typeof t&&"function"==typeof t.emit&&q.nextTick.runAfter(function(){var n=p(_,e);-1!==n&&(t.emit("rejectionHandled",A[r],e),_.splice(n,1))}),L.splice(r,1),A.splice(r,1))}}(this),r?r(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,r){U&&("object"==typeof t&&"function"==typeof t.emit&&q.nextTick.runAfter(function(){-1!==p(L,e)&&(t.emit("unhandledRejection",r,e),_.push(e))}),L.push(e),r&&void 0!==r.stack?A.push(r.stack):A.push("(no stack) "+r))}(r,e),r}function B(e){return w({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},delete:function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return y(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function Q(e,t,r){return q(e).spread(t,r)}function Y(e,t,r){return q(e).dispatch(t,r)}function W(e){return O(e,function(e){var t=0,r=b();return h(e,function(n,i,o){var s;H(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,O(i,function(n){e[o]=n,0==--t&&r.resolve(e)},r.reject,function(e){r.notify({index:o,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function X(e){if(0===e.length)return q.resolve();var t=q.defer(),r=0;return h(e,function(n,i,o){var s=e[o];r++,O(s,function(e){t.resolve(e)},function(e){if(0==--r){var n=e||new Error(""+e);n.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+n.message,t.reject(n)}},function(e){t.notify({index:o,value:e})})},void 0),t.promise}function K(e){return O(e,function(e){return e=f(e,q),O(W(f(e,function(e){return O(e,o,o)})),function(){return e})})}q.resetUnhandledRejections=N,q.getUnhandledReasons=function(){return A.slice()},q.stopUnhandledRejectionTracking=function(){N(),U=!1},N(),q.reject=V,q.fulfill=B,q.master=function(e){return w({isDef:function(){}},function(t,r){return Y(e,t,r)},function(){return q(e).inspect()})},q.spread=Q,w.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},q.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=r[e](t)}catch(e){return V(e)}return o.done?q(o.value):O(o.value,n,i)}try{o=r[e](t)}catch(e){return function(e){return"[object StopIteration]"===g(e)||e instanceof u}(e)?q(e.value):V(e)}return O(o,n,i)}var r=e.apply(this,arguments),n=t.bind(t,"next"),i=t.bind(t,"throw");return n()}},q.spawn=function(e){q.done(q.async(e)())},q.return=function(e){throw new u(e)},q.promised=function(e){return function(){return Q([this,W(arguments)],function(t,r){return e.apply(t,r)})}},q.dispatch=Y,w.prototype.dispatch=function(e,t){var r=this,n=b();return q.nextTick(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},q.get=function(e,t){return q(e).dispatch("get",[t])},w.prototype.get=function(e){return this.dispatch("get",[e])},q.set=function(e,t,r){return q(e).dispatch("set",[t,r])},w.prototype.set=function(e,t){return this.dispatch("set",[e,t])},q.del=q.delete=function(e,t){return q(e).dispatch("delete",[t])},w.prototype.del=w.prototype.delete=function(e){return this.dispatch("delete",[e])},q.mapply=q.post=function(e,t,r){return q(e).dispatch("post",[t,r])},w.prototype.mapply=w.prototype.post=function(e,t){return this.dispatch("post",[e,t])},q.send=q.mcall=q.invoke=function(e,t){return q(e).dispatch("post",[t,l(arguments,2)])},w.prototype.send=w.prototype.mcall=w.prototype.invoke=function(e){return this.dispatch("post",[e,l(arguments,1)])},q.fapply=function(e,t){return q(e).dispatch("apply",[void 0,t])},w.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},q.try=q.fcall=function(e){return q(e).dispatch("apply",[void 0,l(arguments,1)])},w.prototype.fcall=function(){return this.dispatch("apply",[void 0,l(arguments)])},q.fbind=function(e){var t=q(e),r=l(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(l(arguments))])}},w.prototype.fbind=function(){var e=this,t=l(arguments);return function(){return e.dispatch("apply",[this,t.concat(l(arguments))])}},q.keys=function(e){return q(e).dispatch("keys",[])},w.prototype.keys=function(){return this.dispatch("keys",[])},q.all=W,w.prototype.all=function(){return W(this)},q.any=X,w.prototype.any=function(){return X(this)},q.allResolved=(M=K,D="allResolved",P="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(D+" is deprecated, use "+P+" instead.",new Error("").stack),M.apply(M,arguments)}),w.prototype.allResolved=function(){return K(this)},q.allSettled=function(e){return q(e).allSettled()},w.prototype.allSettled=function(){return this.then(function(e){return W(f(e,function(e){function t(){return e.inspect()}return(e=q(e)).then(t,t)}))})},q.fail=q.catch=function(e,t){return q(e).then(void 0,t)},w.prototype.fail=w.prototype.catch=function(e){return this.then(void 0,e)},q.progress=function(e,t){return q(e).then(void 0,void 0,t)},w.prototype.progress=function(e){return this.then(void 0,void 0,e)},q.fin=q.finally=function(e,t){return q(e).finally(t)},w.prototype.fin=w.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw new Error("Q can't apply finally callback");return e=q(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},q.done=function(e,t,r,n){return q(e).done(t,r,n)},w.prototype.done=function(e,r,n){var i=function(e){q.nextTick(function(){if(C(e,o),!q.onerror)throw e;q.onerror(e)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},q.timeout=function(e,t,r){return q(e).timeout(t,r)},w.prototype.timeout=function(e,t){var r=b(),n=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),r.reject(t)},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},q.delay=function(e,t){return void 0===t&&(t=e,e=void 0),q(e).delay(t)},w.prototype.delay=function(e){return this.then(function(t){var r=b();return setTimeout(function(){r.resolve(t)},e),r.promise})},q.nfapply=function(e,t){return q(e).nfapply(t)},w.prototype.nfapply=function(e){var t=b(),r=l(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},q.nfcall=function(e){var t=l(arguments,1);return q(e).nfapply(t)},w.prototype.nfcall=function(){var e=l(arguments),t=b();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},q.nfbind=q.denodeify=function(e){if(void 0===e)throw new Error("Q can't wrap an undefined function");var t=l(arguments,1);return function(){var r=t.concat(l(arguments)),n=b();return r.push(n.makeNodeResolver()),q(e).fapply(r).fail(n.reject),n.promise}},w.prototype.nfbind=w.prototype.denodeify=function(){var e=l(arguments);return e.unshift(this),q.denodeify.apply(void 0,e)},q.nbind=function(e,t){var r=l(arguments,2);return function(){var n=r.concat(l(arguments)),i=b();return n.push(i.makeNodeResolver()),q(function(){return e.apply(t,arguments)}).fapply(n).fail(i.reject),i.promise}},w.prototype.nbind=function(){var e=l(arguments,0);return e.unshift(this),q.nbind.apply(void 0,e)},q.nmapply=q.npost=function(e,t,r){return q(e).npost(t,r)},w.prototype.nmapply=w.prototype.npost=function(e,t){var r=l(t||[]),n=b();return r.push(n.makeNodeResolver()),this.dispatch("post",[e,r]).fail(n.reject),n.promise},q.nsend=q.nmcall=q.ninvoke=function(e,t){var r=l(arguments,2),n=b();return r.push(n.makeNodeResolver()),q(e).dispatch("post",[t,r]).fail(n.reject),n.promise},w.prototype.nsend=w.prototype.nmcall=w.prototype.ninvoke=function(e){var t=l(arguments,1),r=b();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},q.nodeify=function(e,t){return q(e).nodeify(t)},w.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){q.nextTick(function(){e(null,t)})},function(t){q.nextTick(function(){e(t)})})},q.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var J=R();return q})}).call(this,r(3),r(6).setImmediate)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var a,u=[],l=!1,h=-1;function p(){l&&a&&(l=!1,a.length?u=a.concat(u):h=-1,u.length&&f())}function f(){if(!l){var e=c(p);l=!0;for(var t=u.length;t;){for(a=u,u=[];++h<t;)a&&a[h].run();h=-1,t=u.length}a=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new d(e,t)),1!==u.length||l||c(f)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,r){"use strict";r.r(t);var n=r(0);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 o(e){for(var t in e)return!0;return!1}function s(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 a(e,t){if(void 0===e)return!1;for(var r=0,n=t;r<n.length;r++){var i=n[r];if(void 0===e[i])return!1;e=e[i]}return!0}function u(e,t,r){for(var n=0;n<t.length;n++){var i=t[n];void 0===e[i]&&(e[i]=r[n]),e=e[i]}return e}function l(e,t,r){if(void 0===r&&(r=!1),void 0!==e){for(var n=0,i=t;n<i.length;n++)if(void 0===(e=e[i[n]])&&!r)return;return e}}function h(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return function e(t,r,n){for(var i=0,o=r.length;i<o;++i){var s=r[i];if(p(s)||m(s))for(var c=Object.keys(s),a=0,u=c.length;a<u;a++){var l=c[a],h=s[l];n&&p(h)?f(h)?t[l]=new Date(h.valueOf()):v(h)?t[l]=new RegExp(h):h.nodeName?t[l]=h.cloneNode(!0):(y=h)&&(y.nodeName||y.prop&&y.attr&&y.find)?t[l]=h.clone():(p(t[l])||(t[l]=d(h)?[]:{}),e(t[l],[h],!0)):t[l]=h}}var y;return t}(e,t,!1)}function p(e){return null!==e&&"object"==typeof e}function f(e){return"[object Date]"===toString.call(e)}var d=Array.isArray;function m(e){return"function"==typeof e}function v(e){return"[object RegExp]"===toString.call(e)}function y(e){return e&&e.window===e}function g(e){return void 0!==e}function S(e,t,r){void 0===r&&(r=5);var n=[],i=[];if("number"!=typeof r&&(r=5),t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(d(t))t.length=0;else for(var o in t)delete t[o];return n.push(e),i.push(t),s(e,t,r)}return c(e,r);function s(e,t,r){if(--r<0)return"...";if(d(e))for(var n=0,i=e.length;n<i;n++)t.push(c(e[n],r));else if(null===(s=e)||"object"!=typeof s||Object.getPrototypeOf(s))if(e&&"function"==typeof e.hasOwnProperty)for(var o in e)e.hasOwnProperty(o)&&(t[o]=c(e[o],r));else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=c(e[o],r));else for(var o in e)t[o]=c(e[o],r);var s;return t}function c(e,t){if(void 0===t&&(t=5),!p(e))return e;var r=n.indexOf(e);if(-1!==r)return i[r];if(y(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");var o=!1,a=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(c(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){var t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(new Uint8Array(e)),t}return e.slice(0);case"[object Boolean]":case"[object Number]":case"[object String]":case"[object Date]":return new e.constructor(e.valueOf());case"[object RegExp]":var r=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return r.lastIndex=e.lastIndex,r;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(m(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===a&&(a=d(e)?[]:Object.create(Object.getPrototypeOf(e)),o=!0),n.push(e),i.push(a),o?s(e,a,t):a}}var C,I=function(){function e(){this.MOMENT_INVALID="Invalid date",this.SERVER_DATETIME_FORMAT="YYYY-MM-DD[T]HH:mm:ssZ",this.SERVER_TIME_FORMAT="HH:mm:ss",this.SERVER_DATE_FORMAT="YYYY-MM-DD"}return e.prototype.formatResponse=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.path]=this.formatResponseValue(i.apiColumn.type,e[i.path])}},e.prototype.expandResponse=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n];e[o.path]=this.formatResponseValue(o.apiColumn.type,t[o.path])}},e.prototype.formatRequest=function(e,t,r){for(var n={},i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,a=s.apiColumn;a.readOnly||this.compareFields(a.type,e[c],t[c])||(n[c]=this.formatRequestValue(s.apiColumn.type,t[c]))}return n},e.prototype.hasChanges=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.id,c=o.apiColumn;if(!c.readOnly&&!this.compareFields(c.type,e[s],t[s]))return!0}return!1},e.prototype.getChanges=function(e,t,r){for(var n=[],i=0,o=r;i<o.length;i++){var s=o[i],c=s.id,a=s.apiColumn;a.readOnly||this.compareFields(a.type,e[c],t[c])||n.push({oldValue:e[c],newValue:t[c],column:s.apiColumn})}return n},e.prototype.copyFields=function(e,t,r){for(var n=0,i=r;n<i.length;n++){var o=i[n],s=o.path;t[s]=this.clone(o.apiColumn.type,e[s])}return t},e.prototype.shallowCopyFields=function(e,t,r,n){for(var i=0,o=n;i<o.length;i++){var s=o[i],c=s.path;r[c]=void 0!==e[c]?e[c]:this.clone(s.apiColumn.type,t[c])}return r},e.prototype.setDefaultValues=function(e,t){for(var r=0,n=t;r<n.length;r++){var i=n[r];e[i.id]=this.getDefaultValue(i.apiColumn.type)}return e},e.prototype.compareFields=function(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return function e(t,r){if(t===r)return!0;if(null===t||null===r)return!1;if(t!=t&&r!=r)return!0;var n,i,o,s,c,a=typeof t;if(a===typeof r&&"object"===a){if(!d(t)){if(f(t))return!!f(r)&&((s=t.getTime())===(c=r.getTime())||s!=s&&c!=c);if(v(t))return!!v(r)&&t.toString()===r.toString();if(y(t)||y(r)||d(r)||f(r)||v(r))return!1;for(i in o=Object.create(null),t)if(!m(t[i])){if(!e(t[i],r[i]))return!1;o[i]=!0}for(i in r)if(!(i in o)&&g(r[i])&&!m(r[i]))return!1;return!0}if(!d(r))return!1;if(n=t.length,t.length===r.length){for(i=0;i<n;i++)if(!e(t[i],r[i]))return!1;return!0}}return!1}(t,r)}},e.prototype.compareFloats=function(e,t){var r=Math.abs(e),n=Math.abs(t),i=Math.abs(e-t);return e===t||(0===e||0===t||i<Number.MIN_VALUE?i<1.19e-7*Number.MIN_VALUE:i/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?JSON.parse(t):t;case"number":return 0===t?null:t;case"filesize":return t/1e6;default:return t}},e.prototype.formatRequestValue=function(e,t){switch(e){case"datetime":return this.formatRequestDateTime(t);case"date":return this.formatRequestDate(t);case"color":return this.formatRequestColor(t);case"duration":return this.formatRequestDuration(t);case"number":return 0===t?null:t;default:return t}},e.prototype.formatResponseDate=function(e){return null===e?n.invalid():n(e)},e.prototype.formatResponseDuration=function(e){return n.duration(null===e?0:e,"seconds")},e.prototype.formatResponseColor=function(e){return"#"===e.charAt(0)?e:"#"+e},e.prototype.formatRequestDateTime=function(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null},e.prototype.formatRequestDate=function(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null},e.prototype.formatRequestDuration=function(e){return e.asSeconds()},e.prototype.formatRequestColor=function(e){return"#"===e.charAt(0)?e.substring(1):e},e.prototype.getDefaultValue=function(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return n.invalid();case"duration":return n.duration();case"text":case"longtext":return"";case"color":return"#000000";default:return""}},e.prototype.isDefaultValue=function(e,t){return this.compareFields(e,t,this.getDefaultValue(e))},e.prototype.clone=function(e,t){switch(e){case"duration":return this.cloneDuration(t);case"date":case"datetime":return n(t);case"json":return S(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}(),E=function(){function e(e,t){this.queryParserFactory=e,this.queryService=t}return e.prototype.processOptions=function(e){return i(e,{columns:[],query:null,queryItemType:null,queryParams:{},parent:null,deferRequest:!1,limit:null,entryKey:"",addLocalItems:!1})},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 i=this.queryParserFactory.construct(t,e.queryParams).parse();return{object:i[0],string:i[1]}},e.prototype.getIdArray=function(e,t){void 0===t&&(t=[]);for(var r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.itemId)}return t},e.prototype.filterArray=function(e,t){for(var r=[],n=[],i=0,o=e;i<o.length;i++){var s=o[i];t(s)?r.push(s):n.push(s)}if(0===n.length)return n;e.length=r.length;for(var c=0;c<e.length;c++)e[c]=r[c];return n},e}(),R={CACHED:"cached",PROMISED:"promised",EXPAND:"expand",PROMISED_EXPAND:"promised-expand",RESOLVE:"resolve",LOCAL:"local"},q=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.errorHandler=e,this.itemRequestService=t,this.itemHandler=r,this.columnHandler=n,this.collectionEntryFactory=i,this.collectionCacheFactory=o,this.queryParserFactory=s,this.collectionEntryService=c,this.columnSetFactory=a,this.itemEntryService=u,this.keyService=l,this.promiseService=h,this.queryService=p,this.columnUtil=f,this.entries=this.collectionCacheFactory.construct()}return e.prototype.getPromises=function(e){var t=e[R.PROMISED],r=e[R.PROMISED_EXPAND],n=[];for(var i in t)n.push(t[i]);for(var i in r)n.push(r[i]);return n},e.prototype.getRequestIds=function(e){var t=[];for(var r in e[R.RESOLVE])t.push(r);for(var r in e[R.EXPAND])t.push(r);return t},e.prototype.removeFromAndAddToCollections=function(e,t){for(var r in e){var n=e[r],i=n.collection;i.removeItems(n.notfitting,null,!0),i.addItems(n.fitting,null,!0),n.maybe.length>0&&i.extend(Pe,null,!0,t)}},e.prototype.removeFromCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){for(var o=e[i],s=o.fitting,c=o.maybe,a=o.collection,u=[],l=0,h=s;l<h.length;l++){var p=h[l];u.push(p.itemId)}for(var f=0,d=c;f<d.length;f++){var m=d[f];u.push(m)}null!==r&&a===r.entry?n=a.removeItems(u,r,t):a.removeItems(u,null,t)}return n},e.prototype.addItemsToCollections=function(e){return this.addToCollections(this.createCollectionMap(e),!1)},e.prototype.addToCollections=function(e,t,r){var n;for(var i in void 0===r&&(r=null),e){var o=e[i],s=o.collection;s.isDeferred()||(null!==r&&s===r.entry?n=s.addItems(o.fitting,r,t):s.addItems(o.fitting,null,t),t&&o.maybe.length>0&&s.extend(Pe,null,!0,t))}return n},e.prototype.batchExpand=function(e,t,r,n){var i=this;if(0===n.length)return this.promiseService.when(r);var o=[],s=[];for(var c in r)o.push(c),s=s.concat(r[c].entry.items);return this.itemRequestService.requestLinkItems(e,o,t,null,n).then(function(e){for(var c=i.itemRequestService.processExpansion(n,e,t,s),a=0,u=o;a<u.length;a++){var l=u[a];r[l].entry.updateColumns(c)}})},e.prototype.batchExtend=function(e,t,r,n,i,s){var c=this;if(void 0===s&&(s=!1),!o(i))return{};var a=[],u=[];for(var l in r.queryParams=n(r.queryParams),i){var h=i[l].entry;h.extendQuery(n),a.push(l),u=u.concat(h.getIdArray())}return this.itemRequestService.requestLinkItems(e,a,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(u)),r.columns).then(function(n){return c.itemRequestService.processLinkResponse(n,e,a,t,r)},this.errorHandler.reject).then(function(e){for(var t={},r=0,n=a;r<n.length;r++){var o=n[r],c=i[o],u=c.entry.addItems(e.items[o],c);t[o]=s?c.items:u}return t},this.errorHandler.reject)},e.prototype.batchFetch=function(e,t,r,n,i){var s=this,c=this.createStatusResource(e,t,r,n,i);return this.promiseService.all(this.getPromises(c)).then(function(){var t=s.getRequestIds(c);return t.length>0?s.itemRequestService.requestLinkItems(e,t,r,null===n.query?null:s.queryParserFactory.construct(n.query,n.queryParams).parse()[0],n.columns).then(function(i){return s.itemRequestService.processLinkResponse(i,e,t,r,n)},s.errorHandler.reject).then(function(e){return s.handleBatchResponse(c,e)},s.errorHandler.reject):o(c[R.LOCAL])?s.columnHandler.fetch(r,n.columns).then(function(e){return s.handleBatchResponse(c,{columns:s.columnSetFactory.construct(r,n.columns,e,!1)})},s.errorHandler.reject):c[R.CACHED]},this.errorHandler.reject)},e.prototype.clone=function(e,t,r){void 0===r&&(r={});var n=e.itemType,i=e.items,o=[];void 0===r[n]&&(r[n]={});for(var s=r[n],c=0,a=i;c<a.length;c++)s[a[c].itemId]=this.keyService.getLocalId();for(var u=0,l=i;u<l.length;u++){var h=l[u],p=this.itemHandler.cloneItem(s[h.itemId],h,r);null!==t.parent&&(p.parent=t.parent),o.push(p)}return this.create(n,t,e.columns,o)},e.prototype.create=function(e,t,r,n){return this.entries.add(this.collectionEntryFactory.construct(e,t)).resolve({columns:r,items:n})},e.prototype.createCollectionMap=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r];this.expandCollectionMap(i,t)}return t},e.prototype.createStatusResource=function(e,t,r,n,i){var o={};for(var s in R)o[R[s]]={};for(var c=0,a=t;c<a.length;c++){var u,l=a[c],h=this.collectionEntryService.processOptions(n);h.parent={itemType:e,itemId:l},o[(u=this.getEntryStatus(r,h,i)).status][l]=u.entry}return o},e.prototype.expandCollectionMap=function(e,t,r){void 0===r&&(r=this.entries);var n=void 0!==e.parent?e.parent:{},i=r.getByFittingItem(n.itemType,n.itemId,e.itemType,this.itemEntryService.getFields(e));for(var o in i)for(var s=0,c=i[o];s<c.length;s++){var a=c[s],u=a.id;void 0===t[u]&&(t[u]={collection:a,fitting:[],notfitting:[],maybe:[]}),t[u][o].push("fitting"===o?e:e.itemId)}},e.prototype.fetch=function(e,t,r,n){var i=this.getEntryStatus(e,t,n),o=i.entry;switch(i.status){case R.CACHED:return this.promiseService.when(o);case R.PROMISED:return o.promise;case R.EXPAND:return o.expand(t.columns);case R.PROMISED_EXPAND:return o.promise.then(function(){return o.expand(t.columns)},this.errorHandler.reject);case R.RESOLVE:return this.resolveRemote(o,r);case R.LOCAL:return this.resolveLocal(o,r)}},e.prototype.getDeferredEntryStatus=function(e,t){var r=e.options,n=r.columns,i=!1;return e.reloadQueued?(e.reloadQueued=!1,r.columns=this.columnUtil.mergeRequestColumns(t.columns,n).merged,{entry:e,status:e.isLocal()?R.LOCAL:R.RESOLVE}):(!0===n?(console.warn("Columns: true for collections is deprecated!"),i=!0):i=this.columnUtil.isColumnSubset(t.columns,n,!1),{entry:e,status:i?R.PROMISED:R.PROMISED_EXPAND})},e.prototype.getEntryStatus=function(e,t,r){var n=this.collectionEntryService.createQuery(t),i=this.entries.getByQuery(e,n);return null===i?this.getNewEntryStatus(e,n,t,r):i.isDeferred()?this.getDeferredEntryStatus(i,t):{entry:i,status:this.columnUtil.isColumnSubset(t.columns,i.columns.request,i.columns.true)?R.CACHED:R.EXPAND}},e.prototype.getNewEntryStatus=function(e,t,r,n){var i,o;if(r.deferRequest){if(null===(i=n.getByQuery(e,t)))return{entry:n.add(this.collectionEntryFactory.construct(e,r)),status:R.PROMISED};(o=i.options).columns=this.columnUtil.mergeRequestColumns(o.columns,r.columns).merged}else i=this.collectionEntryFactory.construct(e,r);return this.entries.add(i),{entry:i,status:i.isLocal()?R.LOCAL:R.RESOLVE}},e.prototype.handleBatchResponse=function(e,t){var r={};for(var n in e.cached)r[n]=e.cached[n];for(var n in e.resolve)r[n]=e.resolve[n].resolve({items:t.items[n],columns:t.columns});for(var n in e.expand)(i=e.expand[n]).updateColumns(t.columnExpansion),r[n]=i;for(var n in e.local){var i=e.local[n];r[n]=i.resolve({items:this.itemHandler.entries.getByParent(i.parent.itemType,n,i.itemType),columns:t.columns})}return r},e.prototype.removeItemsFromAndAddItemsToCollections=function(e){return this.removeFromAndAddToCollections(this.createCollectionMap(e),!1)},e.prototype.removeItemsFromCollections=function(e){return this.removeFromCollections(this.createCollectionMap(e),!1)},e.prototype.resolveLocal=function(e,t){var r=this,n=e.itemType,i=e.options.columns;return this.columnHandler.fetch(n,i).then(function(o){return e.resolve({items:t.getByQuery(n,e.query),columns:r.columnSetFactory.construct(n,i,o,!1)})},this.errorHandler.reject)},e.prototype.resolveRemote=function(e,t){var r,n=this,i=e.itemType,o=e.options;return this.itemRequestService.requestItems(e).then(function(t){return r=n.columnSetFactory.construct(i,o.columns,t.fetchColumnsObject()),n.itemRequestService.processResponse(t,t.links[i],e.parent,r)},this.errorHandler.reject).then(function(n){return e.resolve({items:n.concat(o.addLocalItems?t.getLocalByQuery(i,e.query):[]),columns:r})},this.errorHandler.reject)},e}(),T=function(){function e(){}return e.prototype.processOptions=function(e){return i(e,{editItems:!1,editCollection:!1,modInstant:!1,enableSave:!0,onItemsCreated:De,onChange:De,onAdd:De,onRemove:De,onAddInitial:De,onRemoveInitial:De,onDeactiveateItem:De,onDeactivateCollection:De,resourceKey:null,clearOnTabChange:!0,clearOnSubTabChange:!0,custom:null})},e.prototype.getIdArray=function(e){for(var t=[],r=0,n=e;r<n.length;r++){var i=n[r];t.push(i.entry.itemId)}return t},e}(),b=function(){function e(e){this.columnUtil=e,this.cache={},this.allColumns={}}return e.prototype.setColumn=function(e,t){void 0===this.cache[e]&&(this.cache[e]={});var r=this.cache[e],n=t.id;return void 0===r[n]&&(r[n]=t),r[n]},e.prototype.setColumns=function(e,t,r){var n={};for(var i in r){var o=r[i];for(var s in n[i]={},o)n[i][s]=this.setColumn(i,o[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),{missing:n,cached:r}},e.prototype.containsAll=function(e){return!0===this.allColumns[e]},e.prototype.getColumns=function(e){var t=void 0===this.cache[e]?[]:this.cache[e],r={};return r[e]=t,r},e.prototype.retrieveColumns=function(e,t,r,n){this.retrieveColumn(e,"id",r,n);for(var i=0,o=t;i<o.length;i++){var s=o[i];this.retrieveColumn(e,s,r,n)}},e.prototype.retrieveColumn=function(e,t,r,n){var i=this.columnUtil.parseRequestColumn(t),o=this.getColumn(e,i.id);if(void 0!==o){if(void 0===n[e]&&(n[e]={}),n[e][i.id]=o,0!==i.children.length){var s=[];if(this.retrieveColumns(o.itemType,i.children,s,n),0!==s.length){var c={};c[i.id]=s,r.push(c)}}}else r.push(t)},e.prototype.getColumn=function(e,t){if(void 0!==this.cache[e])return this.cache[e][t]},e}(),F=function(){function e(e,t,r,n,i){this.apiRequestService=e,this.errorHandler=t,this.promiseService=r,this.cache=n,this.columnUtil=i}return e.prototype.setColumn=function(e,t){this.cache.setColumn(e,t)},e.prototype.setColumns=function(e,t,r){this.cache.setColumns(e,t,r)},e.prototype.fetchItemTypeTranslations=function(e){for(var t=[],r={},n=0,i=e;n<i.length;n++){var o=i[n],s=t.push(this.fetch(o,["id"]));r[o]=s-1}return this.promiseService.all(t).then(function(e){for(var t={},n=0;n<e.length;n++){var i=r[n];t[i]=e[i][i].id.name}return t},this.errorHandler.reject)},e.prototype.request=function(e,t,r){var n,i=this;void 0===r&&(r={});var o=((n={})[e]=t,n);return this.apiRequestService.columns(e,o,r).then(function(r){return i.cache.setColumns(e,t,r.fetchColumnsObject())},this.errorHandler.reject)},e.prototype.fetch=function(e,t,r){var n=this;void 0===r&&(r={});var i=this.cache.retrieve(e,t);return!0!==i.missing&&0===i.missing.length?this.promiseService.when(i.cached):this.request(e,i.missing,r).then(function(e){return n.columnUtil.mergeResponseColumns(e,i.cached).merged})},e.prototype.fetchAll=function(e){return this.cache.containsAll(e)?this.promiseService.when(this.cache.getColumns(e)):this.request(e,!0)},e}(),k=function(){function e(){}return e.prototype.getColumnPath=function(e,t){for(var r="",n="",i=0,o=e;i<o.length;i++)n+=r+o[i].id,r=">";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&&h(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.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"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.isColumnSubset=function(e,t,r){if(!0===e)return r;for(var n=0,i=e;n<i.length;n++){var o=i[n];if(!this.containsColumn(o,t))return!1}return!0},e.prototype.containsColumn=function(e,t){var r=this.parseRequestColumn(e),n=this.findColumn(r.id,t);if(-1===n)return!1;if(0===r.children.length)return!0;if("string"==typeof t[n])return!1;for(var i=0,o=r.children;i<o.length;i++){var s=o[i];if(!this.containsColumn(s,t[n][r.id]))return!1}return!0},e.prototype.responseColumnsAvailable=function(e,t,r){for(var n=0,i=t;n<i.length;n++){var o,s=i[n],c=this.parseRequestColumn(s),a=c.children,u=r[e];if(void 0===u)return!1;if(void 0===(o=u[c.id]))return!1;if(a.length>0&&!this.responseColumnsAvailable(o.itemType,a,r))return!1}return!0},e.prototype.mergeRequestColumns=function(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};for(var r=S(e),n=[],i=0,o=t;i<o.length;i++){var s=o[i],c=this.mergeRequestColumn(s,r);null!==c&&n.push(c)}return{merged:r,difference:n}},e.prototype.mergeRequestColumn=function(e,t){var r,n,i=this.parseRequestColumn(e),o=this.findColumn(i.id,t);if(-1===o)return t.push(e),e;if(0===i.children.length)return null;"string"==typeof t[o]&&(t[o]=((r={})[i.id]=[],r));for(var s=[],c=0,a=i.children;c<a.length;c++){var u=a[c],l=this.mergeRequestColumn(u,t[o][i.id]);null!==l&&s.push(l)}return 0===s.length?null:((n={})[i.id]=s,n)},e.prototype.parseRequestColumn=function(e){var t="string"==typeof e,r=t?e:s(e);return{id:r,children:t?[]:e[r]}},e.prototype.mergeResponseColumns=function(e,t){var r={},n={};for(var i in e)if(void 0!==t[i]){var o=this.mergeResponseColumnMap(e[i],t[i]);r[i]=o.merged,n[i]=o.difference}else r[i]=e[i];for(var i in t)void 0===e[i]&&(r[i]=t[i],n[i]=t[i]);return{merged:r,difference:n}},e.prototype.mergeResponseColumnMap=function(e,t){var r={},n={};for(var i in e)r[i]=e[i];for(var i in t)g(e[i])||(r[i]=t[i],n[i]=t[i]);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 i=n[r];this.isLocalColumnId(i)||this.processConfigColumn(this.parseConfigColumn(i),t)}return t},e.prototype.processLocalConfigColumns=function(e,t,r,n){for(var i={},o=0,s=t;o<s.length;o++){var c=s[o];i[c.id]=c}for(var a=0,u=e;a<u.length;a++){var l=u[a],h=l.split(":"),p=h[0];this.isLocalColumnId(p)?void 0!==i[p]&&(n(l,i[p]),delete i[p]):r(l,p,h[1])}},e.prototype.consolidateColumns=function(e,t,r){var n=this,i=[],o=S(r);return this.processLocalConfigColumns(e,t,function(e,t){n.processConfigColumn(t.split(">"),o)},function(e,t){i.push(t),o=n.mergeRequestColumns(o,t.valueOptions.requestColumns).merged}),{request:o,local:i}},e.prototype.parseConfigColumn=function(e){return e.split(":")[0].split(">")},e.prototype.processConfigColumn=function(e,t){var r,n=e[0];if(1===e.length)-1===t.indexOf(n)&&t.push(n);else{var i=this.findColumnObject(n,t);-1===i&&(i=t.push(((r={})[n]=[],r))-1),this.processConfigColumn(e.slice(1),t[i][n])}},e.prototype.findColumnObject=function(e,t){for(var r=0;r<t.length;r++)if(s(t[r])===e)return r;return-1},e.prototype.findColumn=function(e,t){for(var r=0;r<t.length;r++){var n=t[r];if("string"!=typeof n){if(s(n)===e)return r}else if(n===e)return r}return-1},e}(),w=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f,d){this.apiRequestService=e,this.resourceCacheInterface=t,this.authInterface=r,this.errorHandler=n,this.itemHandler=i,this.collectionHandler=o,this.columnSetFactory=s,this.itemRequestService=c,this.resourceCacheFactory=a,this.moduleChangesCompilerFactory=u,this.collectionEntryService=l,this.collectionResourceService=h,this.itemEntryService=p,this.keyService=f,this.queryService=d}return e.prototype.getItemDefinition=function(e,t,r){var n=this.keyService.parseStateKey(t),i={itemType:e,options:r,itemId:t};if(null!==n){switch(n.type){case"new":i.itemId=this.keyService.getLocalId();break;case"duplicate":r.duplicate=n.itemId,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=n.itemId),i.itemId=this.keyService.getLocalDuplicateId()}return i}return i.itemId=t,i},e.prototype.createCollectionMap=function(e,t){for(var r=this.getResourceCache(),n=r.collections,i={},o=0,s=e;o<s.length;o++){var c=s[o];t&&r.addSingleItem(c,{},!1),this.collectionHandler.expandCollectionMap(c,i,n)}return i},e.prototype.getItemById=function(e,t,r){var n=this;return this.itemHandler.fetchItem(e,t,r).then(function(e){return n.addSingleItem(e,r,!1)},this.errorHandler.reject)},e.prototype.getItemsById=function(e,t,r){var n=this;return this.itemHandler.fetchItems(e,t,this.itemEntryService.processOptions(r)).then(function(e){return n.addSingleItems(e,r)},this.errorHandler.reject)},e.prototype.getItemsByQuery=function(e,t,r){var n=this,i=this.itemEntryService.processOptions(r),o={};return o[e]=i.columns,this.apiRequestService.query(e,this.queryService.addParentCondition(t,i.parent),o).then(function(t){return n.itemRequestService.processResponse(t,t.links[e],i.parent,n.columnSetFactory.construct(e,i.columns,t.fetchColumnsObject()))},this.errorHandler.reject).then(function(e){return n.addSingleItems(e,r)},this.errorHandler.reject)},e.prototype.getDuplicateById=function(e,t,r){void 0===r&&(r={}),r.edit=!0;var n=this.getItemDefinition(e,this.keyService.getDuplicateStateKey(t),r);return this.getItemByDef(n,!1)},e.prototype.getNewResource=function(e,t,r,n){var i=this;return void 0===t&&(t={}),t.edit=!0,void 0===n&&(n=!1),this.itemHandler.fetchItem(e,this.keyService.getLocalId(),this.itemEntryService.processOptions(t)).then(function(e){var o=i.addSingleItem(e.main,t,n),s=i.processLinkedItems(e.linked,t,!0);return r?{main:o,linked:s}:o},this.errorHandler.reject)},e.prototype.getCollectionDef=function(e,t){return{itemType:e,options:{entry:this.collectionEntryService.processOptions(t),resource:this.collectionResourceService.processOptions(t)}}},e.prototype.getLinkCollectionsDef=function(e,t,r,n,i){return{itemType:r,linkType:e,linkIdArray:t,linkField:n,options:{entry:this.collectionEntryService.processOptions(i),resource:this.collectionResourceService.processOptions(i)}}},e.prototype.getCollection=function(e,t,r){var n=this,i=this.getResourceCache(),o=this.collectionEntryService.processOptions(r);return o.query=t,this.collectionHandler.fetch(e,o,i.items,i.deferredCollections).then(function(e){return n.addCollection(e,r)},this.errorHandler.reject)},e.prototype._getCollection=function(e,t){var r=this,n=this.getResourceCache();return this.collectionHandler.fetch(e,this.collectionEntryService.processOptions(t),n.items,n.deferredCollections).then(function(e){return r.addCollection(e,t)},this.errorHandler.reject)},e.prototype.getCollectionFromDef=function(e){var t=this,r=this.getResourceCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,r.items,r.deferredCollections).then(function(r){return t.addCollection(r,e.options.resource,!1)},this.errorHandler.reject)},e.prototype.getLinkCollection=function(e,t,r,n){var i=this,o=this.getResourceCache(),s=this.collectionEntryService.processOptions(n);return s.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,s,o.items,o.deferredCollections).then(function(e){return i.addCollection(e,n)},this.errorHandler.reject)},e.prototype.getLinkCollections=function(e,t,r,n){var i=this;return this.collectionHandler.batchFetch(e,t,r,this.collectionEntryService.processOptions(n),this.getResourceCache().deferredCollections).then(function(e){return i.addCollections(e,i.collectionEntryService.processOptions(n))},this.errorHandler.reject)},e.prototype.getLinkCollectionsFromDef=function(e){var t=this;return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,this.getResourceCache().deferredCollections).then(function(r){return t.addCollections(r,e.options.resource)},this.errorHandler.reject)},e.prototype.getAllLinkCollections=function(e,t,r){var n=this;return this.apiRequestService.query(e,{},{}).then(function(i){return n.getLinkCollections(e,i.links[e],t,r)},this.errorHandler.reject)},e.prototype.getItemByDef=function(e,t){var r=this;return this.itemHandler.fetchItem(e.itemType,e.itemId,this.itemEntryService.processOptions(e.options)).then(function(n){var i;return void 0!==n.linked?(r.processLinkedItems(n.linked,e.options,!1),i=n.main):i=n,r.addSingleItem(i,e.options,t)},this.errorHandler.reject)},e.prototype.cloneItem=function(e,t,r){return this.addSingleItem(this.itemHandler.cloneItem(e,t.entry),r)},e.prototype.cloneCollection=function(e,t,r){return this.addCollection(this.collectionHandler.clone(e.entry,this.collectionEntryService.processOptions(t),r),t)},e.prototype.saveCurrentTab=function(e,t,r,n,i){return this.saveCurrentResourceCache(e,t,r,n,i)},e.prototype.saveCurrentResourceCache=function(e,t,r,n,i){var o=this;return void 0===r&&(r=!1),void 0===i&&(i=!1),this.getResourceCache().save(e,t,r,n).then(function(t){return e?t:o.resourceCacheInterface.updateTabParams(t,!i).then(function(){return t},o.errorHandler.reject)},this.errorHandler.reject)},e.prototype.getCurrentCollections=function(){return this.getResourceCache().collections},e.prototype.getCurrentItems=function(){return this.getResourceCache().items},e.prototype.getCurrentChanges=function(){var e=this.getResourceCache();if(void 0===e.rootItem)throw new Error("itemAdministrator: No root item!");return this.moduleChangesCompilerFactory.construct(e.rootItem,e.items,e.collections).process()},e.prototype.addSingleItem=function(e,t,r){return this.getResourceCache().addSingleItem(e,t,r)},e.prototype.addSingleItems=function(e,t){for(var r=this.getResourceCache(),n=[],i=0,o=e;i<o.length;i++){var s=o[i];n.push(r.addSingleItem(s,t,!1))}return n},e.prototype.addCollection=function(e,t,r){return void 0===r&&(r=!0),this.getResourceCache().addCollection(e,r?this.collectionEntryService.processOptions(t):t)},e.prototype.addCollections=function(e,t){var r=this.getResourceCache(),n={};for(var i in e)n[i]=r.addCollection(e[i],t);return n},e.prototype.processLinkedItems=function(e,t,r){for(var n=this.getResourceCache(),i=n.collections,o={},s=0,c=e;s<c.length;s++){var a=c[s],l=a.itemType,h=a.itemEntries,p={};o[l]=[];for(var f=0,d=h;f<d.length;f++){var m=d[f];o[l].push(n.addSingleItem(m,t,!1)),r&&this.collectionHandler.expandCollectionMap(m,p,i),"Projectnotitie"===l&&u(n.tabRequestParameters,[m.itemType,m.itemId],[{},{no_notification:!0}])}r&&this.collectionHandler.addToCollections(p,!1)}return o},e.prototype.getTabEntry=function(){return this.getResourceCache()},e.prototype.getResourceCache=function(){return this.resourceCacheInterface.getCacheManager(this.authInterface.getUserId())},e.prototype.resetTabEntry=function(){return this.resetResourceCache()},e.prototype.resetResourceCache=function(){var e=this.getResourceCache(),t=this.resourceCacheFactory.construct();e.clearResources(),this.resourceCacheInterface.setCacheManager(this.authInterface.getUserId(),t)},e.prototype.addToCollections=function(e,t){return this.collectionHandler.addToCollections(this.createCollectionMap(e,!0),!1,t)},e.prototype.removeFromCollections=function(e,t){return this.collectionHandler.removeFromCollections(this.createCollectionMap(e,!1),!1,t)},e.prototype.updateItemIdMap=function(e,t){if(void 0!==t)for(var r in t){var n=t[r];void 0!==e[r]&&(e[n]=e[r],delete e[r])}},e.prototype.createCollectionResource=function(e,t,r){return this.addCollection(e,t,r)},e.prototype.createItemResource=function(e,t,r){return this.addSingleItem(e,t,r)},e.prototype.createItemResources=function(e,t){return this.addSingleItems(e,t)},e.prototype.onBeforeSave=function(e,t){return this.getResourceCache().registerCallback("onBeforeSave",e,t)},e.prototype.onSaveSuccess=function(e,t){return this.getResourceCache().registerCallback("onSaveSuccess",e,t)},e.prototype.onSaveWithoutClosing=function(e,t){return this.getResourceCache().registerCallback("onSaveWithoutClosing",e,t)},e}(),O=function(){function e(e,t,r){this.apiFormatter=e,this.keyService=t,this.promiseService=r,this.undefinedItemError="Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken",this.ALL_PERMISSIONS=7}return e.prototype.resetDerived=function(e,t){for(var r=[],n=0,i=e.columns.root;n<i.length;n++){var o=i[n];-1!==t.indexOf(o.id)&&r.push(o)}!function t(r){for(var n=0,i=r;n<i.length;n++){var o=i[n];o.isLeaf||t(o.children),delete e.derived[o.path]}}(r)},e.prototype.defer=function(e,t){return e.deferred=this.promiseService.defer(),e.deferRequest=t,e},e.prototype.resolve=function(e){var t=e.deferred;return delete e.deferred,delete e.deferRequest,t.resolve(e),e},e.prototype.reject=function(e,t){return void 0===t&&(t=this.undefinedItemError),e.deferred.reject(t),delete e.deferred,delete e.deferRequest,e},e.prototype.clearResources=function(e){e.resources=[]},e.prototype.deactivateResources=function(e){for(var t=0,r=e.resources;t<r.length;t++)r[t].deactivate()},e.prototype.getFields=function(e){return void 0!==e.modified?e.modified:e.initial},e.prototype.expand=function(e,t,r,n){var i=n.difference;return e.columns=n.merged,this.apiFormatter.expandResponse(e.initial,t,i.main),this.apiFormatter.expandResponse(e.derived,r,i.derived),void 0===e.modified?e:(this.apiFormatter.expandResponse(e.modified,t,i.main),e)},e.prototype.processOptions=function(e){return i(e,{columns:!0,parent:null,templateOptions:{},templateColumns:{},deferRequest:!1})},e.prototype.getConversionValue=function(e,t,r){if(void 0!==r[e])return r[e][t]},e.prototype.updateFields=function(e,t,r){void 0===r&&(r=!0);var n=e.columns.main,i=e.columns.formatted.main,o=e.initial,s=e.modified;if(void 0!==s){for(var c=0,a=n;c<a.length;c++){var u=(p=a[c]).id;(r||this.apiFormatter.compareFields(p.apiColumn.type,o[u],s[u]))&&(s[u]=t[u])}this.apiFormatter.formatResponse(s,i)}for(var l=0,h=n;l<h.length;l++){var p;o[u=(p=h[l]).id]=t[u]}return this.apiFormatter.formatResponse(o,i),e},e.prototype.updateItemValue=function(e,t,r,n){var i,o=r.id,s=t[o];"link"===r.type&&void 0===s?void 0!==e.parent&&(i=e.parent.itemId):i=this.getConversionValue(r.itemType,s,n),void 0!==i&&(t[o]=i)},e.prototype.updateItemFields=function(e,t){for(var r=e.columns.item,n=e.initial,i=e.modified,o=0,s=r;o<s.length;o++){var c=s[o].apiColumn;this.updateItemValue(e,n,c,t),void 0!==i&&this.updateItemValue(e,i,c,t)}},e.prototype.process=function(e){var t=e.columns.formatted;return this.apiFormatter.formatResponse(e.initial,t.main),this.apiFormatter.formatResponse(e.derived,t.derived),e},e.prototype.formatRequest=function(e){return void 0===e.modified?{}:this.apiFormatter.formatRequest(this.keyService.isLocalId(e.itemId)?{}:e.initial,e.modified,e.columns.main)},e.prototype.setDisplayName=function(e){if(void 0!==e.modified){var t=this.getDisplayName(e);t&&(e.modified.displayname=t)}},e.prototype.getDisplayName=function(e){var t=void 0===e.modified?e.initial:e.modified;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);case"Reparatie":return e.derived["materiaal>naam"];default:return t[this.getTitleField(e.itemType)]}},e.prototype.getFullName=function(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)},e.prototype.getTitleField=function(e){switch(e){case"Exemplaar":return"serienummer";case"Factuur":return"nummer";case"Files":return"friendlyname";case"Functie":case"Standaardfunctie":return"naamintern";case"Voorraadmutatie":return"omschrijving";case"Barcode":return"code";case"Betaalmiddel":case"Betalingsconditie":case"Briefpapier":case"TaxClass":case"TaxSchema":case"Condition":case"Factuurmoment":case"Functiegroep":case"Grootboek":case"Inhuur":case"Inhuurgroep":case"Inhuurmateriaal":case"Materiaal":case"MateriaalCat":case"Medewerkertarief":case"Notitie":case"Planningmateriaal":case"Project":case"Staffelgroep":case"Subproject":case"Taak":case"Tag":case"Template":case"Tijd":case"Titel":case"Type":case"Voertuig":return"naam";default:return"displayname"}},e.prototype.getChanges=function(e,t){return void 0!==e.modified||t?this.apiFormatter.getChanges(e.initial,t?{}:e.modified,e.columns.main):[]},e.prototype.isLocal=function(e){return this.keyService.isLocalId(e.itemId)},e.prototype.isLockable=function(e){if(this.isLocal(e))return!1;switch(e.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}},e.prototype.hasChanges=function(e){return void 0!==e.modified&&this.apiFormatter.hasChanges(e.initial,e.modified,e.columns.main)},e.prototype.resetModified=function(e){var t=e.columns.main;if(void 0!==e.modified)for(var r=0,n=t;r<n.length;r++){var i=n[r];e.modified[i.id]=this.apiFormatter.clone(i.apiColumn.type,e.initial[i.id])}},e.prototype.setInitial=function(e,t,r){var n;for(var i in t)e.initial[i]=t[i];if(void 0===e.modified)return r&&this.callOnChange(e,this.apiFormatter.copyFields(e.initial,{},e.columns.main)),e;for(var i in n=this.apiFormatter.copyFields(e.modified,{},e.columns.main),t)e.modified[i]=t[i];return r&&this.callOnChange(e,n),e},e.prototype.setModified=function(e,t){var r=e.columns,n=r.response[e.itemType];if(void 0===e.modified){var i=e.resources,o=e.initial,s=e.modified={};if(void 0===t)this.apiFormatter.copyFields(o,s,r.main);else for(var c in this.apiFormatter.shallowCopyFields(t,o,s,r.main),t)void 0===n[c]&&(s[c]=t[c]);for(var a=0,u=i;a<u.length;a++)u[a].fields=s;return e}if(void 0===t)return e;for(var c in t)e.modified[c]=t[c];return e},e.prototype.setDerived=function(e,t){for(var r in t)e.derived[r]=t[r];return e},e.prototype.processLocal=function(e,t,r,i,o){return e.initial={permissions:this.ALL_PERMISSIONS},this.updateFields(e,t),this.updateItemFields(e,o),this.setModified(e,r),e.modified.created=n(),e.derived=i,e},e.prototype.setParent=function(e,t,r){return e.parent={itemType:t,itemId:r},e},e.prototype.callOnChange=function(e,t){for(var r=0,n=e.resources.length;r<n;r++){var i=e.resources[r];null!==i&&i.options.onChange(i,t)}},e}(),j=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.authInterface=t,this.errorHandler=r,this.itemEntryFactory=n,this.columnHandler=i,this.itemCacheFactory=o,this.batchStatusFactory=s,this.columnExpansionFactory=c,this.columnSetFactory=a,this.itemEntryService=u,this.apiFormatter=l,this.keyService=h,this.promiseService=p,this.columnUtil=f,this.templates={},this.entries=this.itemCacheFactory.construct()}return e.prototype.getItemId=function(e){return e.itemId},e.prototype.getPromise=function(e){return e.deferred.promise},e.prototype.fetchItem=function(e,t,r){var n=this,i=this.getEntryStatus(e,t,r),o=i.entry,s=i.status;return s===R.LOCAL?this.fetchTemplate(e,r.templateOptions,r.templateColumns).then(function(e){return n.resolveLocal(o,r.parent,e)},function(e){return n.itemEntryService.reject(o,e),e}):this.resolveCached(o,s,r)},e.prototype.fetchItems=function(e,t,r){for(var n=this,i=this.batchStatusFactory.construct(function(e){return n.getItemId(e)},function(e){return n.getPromise(e)}),o={},s=0,c=t;s<c.length;s++){var a=c[s];i.add(this.getEntryStatus(e,a,r))}return o.entries=i.getPromises(),i.hasRequests()&&(o.requests=this.requestItem(e,i.getRequestIds(),r.columns)),i.hasEntries([R.LOCAL])&&(o.template=this.fetchTemplate(e,r.templateOptions,r.templateColumns)),this.promiseService.all(o).then(function(t){return n.batchResolve(e,i,r.columns,t)},this.errorHandler.reject)},e.prototype.resolveCached=function(e,t,r){var n=this,i=e.itemType,o=e.itemId,s=e.columns.request;switch(t){case R.CACHED:return this.promiseService.when(e);case R.PROMISED:return e.deferred.promise;case R.PROMISED_EXPAND:return e.deferred.promise.then(function(){return n.resolveCached(e,n.getCachedEntryStatus(e,r),r)},this.errorHandler.reject)}if(t===R.EXPAND){var c=this.columnUtil.mergeRequestColumns(s,r.columns).difference;this.requestItem(i,o,c).then(function(t){n.resolveExpansion(e,n.columnExpansionFactory.construct(i,c,t.fetchColumnsObject()),t)},function(t){n.itemEntryService.reject(e,t)})}else this.requestItem(i,o,s).then(function(t){n.resolveRemote(e,n.columnSetFactory.construct(i,s,t.fetchColumnsObject()),t)},function(t){n.itemEntryService.reject(e,t)});return e.deferred.promise},e.prototype.resolveLocal=function(e,t,r){var n=e.itemType,i=e.itemId,o=this.createConversionMap(n,i,!0,r.response);return e.columns=r.columns,null!==t&&this.itemEntryService.setParent(e,t.itemType,t.itemId),this.itemEntryService.processLocal(e,r.fields,{},{},o),this.setCreator(e),this.itemEntryService.resolve(e),{main:e,linked:this.createLocalEntries(n,i,r,o)}},e.prototype.resolveExpansion=function(e,t,r){var n=e.itemType,i=e.itemId,o=t(e.columns,!0);return null===o?e:(this.itemEntryService.expand(e,r.fetchObject(n,i),r.fetchDerivedObject(n,i,o.difference.root),o),this.itemEntryService.resolve(e))},e.prototype.resolveRemote=function(e,t,r){var n=e.itemType,i=e.itemId,o=r.fetchObject(n,i);return void 0===o?(this.itemEntryService.reject(e),this.entries.clear(e),null):this.resolveDeferredEntry(e,o,r.fetchDerivedObject(n,i,t.root),t)},e.prototype.fetchTemplate=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r={});var i=o(t),c=s(r);if(!i){var a=this.templates[e];if(void 0!==a&&(null===c||this.columnUtil.responseColumnsAvailable(c,r[c],a.responseColumns)))return this.promiseService.when(a)}return this.promiseService.all([this.apiRequestService.template(e,t),null===c?{}:this.columnHandler.fetch(c,r[c])]).then(function(t){var r=t[0],o=n.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),t[1]).merged,s={fields:r.fetchObject(e,r.links[e][0]),columns:n.columnSetFactory.construct(e,!0,o),response:r,responseColumns:o};return!i&&r.cacheable&&(n.templates[e]=s),s},this.errorHandler.reject)},e.prototype.getEntryStatus=function(e,t,r){var n=this.entries.get(e,t);return void 0===n?this.keyService.isLocalId(t)?{entry:this.createDeferredEntry(e,t,!0,!1),status:R.LOCAL}:{entry:this.createDeferredEntry(e,t,r.columns,r.deferRequest),status:r.deferRequest?R.PROMISED:R.RESOLVE}:{entry:n,status:this.getCachedEntryStatus(n,r)}},e.prototype.getCachedEntryStatus=function(e,t){var r=e.columns,n=this.itemEntryService.isLocal(e)||this.columnUtil.isColumnSubset(t.columns,r.request,r.true);return void 0!==e.deferred?e.deferRequest?(r.request=this.columnUtil.mergeRequestColumns(r.request,t.columns).merged,R.RESOLVE):n?R.PROMISED:R.PROMISED_EXPAND:n?R.CACHED:(this.itemEntryService.defer(e,!1),R.EXPAND)},e.prototype.createDeferredEntry=function(e,t,r,n){var i=this.createEntryStub(e,t);return i.columns={itemType:e,request:r,true:!0===r},this.itemEntryService.defer(i,n)},e.prototype.createEntryStub=function(e,t){return this.entries.add(this.itemEntryFactory.construct(e,t))},e.prototype.createEntry=function(e,t,r,n){return this.itemEntryService.process(this.entries.add(this.itemEntryFactory.construct(n.itemType,e,n,t,r)))},e.prototype.resolveDeferredEntry=function(e,t,r,n){return e.columns=n,e.initial=t,e.derived=r,this.itemEntryService.process(e),this.itemEntryService.resolve(e)},e.prototype.batchResolve=function(e,t,r,n){var i=this,o=n.requests,s=[R.EXPAND,R.PROMISED_EXPAND],c=[R.RESOLVE],a=!0;if(t.hasEntries(s)){var u=this.columnExpansionFactory.construct(e,r,o.fetchColumnsObject());t.forEachEntry(s,function(e){i.resolveExpansion(e,u,o)})}if(t.hasEntries(c)){var l=this.columnSetFactory.construct(e,r,o.fetchColumnsObject());t.forEachEntry(c,function(e){null===i.resolveRemote(e,l,o)&&(a=!1)})}return t.forEachEntry([R.LOCAL],function(e){i.resolveLocal(e,null,n.template)}),a?t.getArray():this.errorHandler.reject({message:this.itemEntryService.undefinedItemError})},e.prototype.cloneItem=function(e,t,r){var n,i,o=t.columns,s=t.parent;void 0===r&&((n={})[t.itemType]=((i={})[t.itemId]=e,i),r=n);var c=this.createEntry(e,this.apiFormatter.copyFields(this.itemEntryService.getFields(t),{},o.main),this.apiFormatter.copyFields(t.derived,{},o.derived),o);return this.itemEntryService.updateItemFields(c,r),c.modified=this.apiFormatter.copyFields(c.initial,{},o.main),s?this.itemEntryService.setParent(c,s.itemType,s.itemId):c},e.prototype.createConversionMap=function(e,t,r,n){var i,o,s=n.links[e][0],c=((i={})[e]=((o={})[s]=t,o),i);return r&&this.extendConversionMap(c,n.items[e][s].links,n),c},e.prototype.createLocalEntries=function(e,t,r,n){var i=this,o=this,s=r.response,c={},a={},u=[];for(var l in s.items)l!==e&&(c[l]=this.columnSetFactory.construct(l,!0,r.responseColumns));var h=function(e,t,r){var l={itemType:e,itemId:t},p=s.items[e][r].links;for(var f in p){var d=p[f];void 0===a[f]&&u.push({itemType:f,itemEntries:a[f]=[]});for(var m=0,v=d;m<v.length;m++){var y=v[m],g=n[f][y],S=o.createEntryStub(f,g);S.columns=c[f],S.parent=l,i.itemEntryService.processLocal(S,s.fetchObject(f,y),{},{},n),i.setCreator(S),a[f].push(S),h(f,g,y)}}};return h(e,t,s.links[e][0]),u},e.prototype.createLocalEntry=function(e,t,r,n,i){void 0===i&&(i=null);var o=t.columns.itemType,s=this.createEntryStub(o,e);return s.columns=t.columns,null!==i&&(s.parent=i),this.itemEntryService.processLocal(s,t.fields,r,n,this.createConversionMap(o,e,!1,t.response)),this.setCreator(s),s},e.prototype.extendConversionMap=function(e,t,r){for(var n in t){var i=t[n];void 0===e[n]&&(e[n]={});for(var o=0,s=i;o<s.length;o++){var c=s[o];e[n][c]=this.keyService.getLocalId(),this.extendConversionMap(e,r.items[n][c].links,r)}}},e.prototype.fetchTitle=function(e,t,r){void 0===r&&(r=!0);var n=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,this.itemEntryService.processOptions({columns:[n],deferRequest:r})).then(function(e){return void 0!==e.main?e.main.initial[n]:void 0!==e.modified?e.modified[n]:e.initial[n]},this.errorHandler.reject)},e.prototype.requestItem=function(e,t,r){var n,i=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},i)},e.prototype.updateItemId=function(e,t){var r=e.itemId;return e.itemId=t,this.entries.updateItemId(e,r)},e.prototype.setCreator=function(e){e.modified.creator=this.authInterface.getUserId(),e.derived["creator>displayname"]=this.authInterface.getUserDisplayname()},e}(),H=function(){function e(e,t,r,n,i,o,s,c,a){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnHandler=n,this.columnExpansionFactory=i,this.columnSetFactory=o,this.itemEntryService=s,this.queryService=c,this.promiseService=a}return e.prototype.requestItem=function(e,t,r){var n,i=((n={})[e]=r,n);return this.apiRequestService.query(e,{id:t},i)},e.prototype.requestItems=function(e,t,r){var n;void 0===t&&(t=e.query.object),void 0===r&&(r=e.options.columns);var i=e.options,o={requestType:"query",columns:((n={})[e.itemType]=r,n),query:t,itemType:"",allLinkIds:!1,limit:null};return null===i.queryItemType?o.itemType=e.itemType:(o.itemType=i.queryItemType,o.allLinkIds=!0),null!==i.limit&&(o.limit=i.limit),this.apiRequestService.requestSkeleton(o)},e.prototype.requestLinkItems=function(e,t,r,n,i){var o,s=((o={})[r]=i,o);return null===n?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(n,{linkedTo:e,query:{id:t}}),s)},e.prototype.processExpansion=function(e,t,r,n){for(var i=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject()),o=0,s=n;o<s.length;o++){var c=s[o];this.itemEntryService.isLocal(c)||this.handleCachedItem(c,t,i)}return i},e.prototype.processResponse=function(e,t,r,n,i){var o=this;void 0===i&&(i=this.columnExpansionFactory.construct(n.itemType,!!n.true||n.request,n.response));for(var s=n.itemType,c=n.root,a=[],u=[],l=0,h=t;l<h.length;l++){var p=h[l],f=this.itemHandler.entries.get(s,p);void 0===f?(f=this.itemHandler.createEntry(p,e.fetchObject(s,p),e.fetchDerivedObject(s,p,c),n),a.push(f)):void 0!==f.deferred?f.deferRequest?a.push(this.itemHandler.resolveDeferredEntry(f,e.fetchObject(s,p),e.fetchDerivedObject(s,p,c),n)):u.push(f.deferred.promise):a.push(this.handleCachedItem(f,e,i)),null!==r&&(f.parent=r)}return this.promiseService.all(u).then(function(t){for(var r=0,n=t;r<n.length;r++){var s=n[r];a.push(o.handleCachedItem(s,e,i))}return a},this.errorHandler.reject)},e.prototype.handleCachedItem=function(e,t,r){var n=r.run(e.columns,!0);return null===n?e:this.itemEntryService.expand(e,t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,n.difference.root),n)},e.prototype.processLinkResponse=function(e,t,r,n,i){for(var o=e.fetchColumnsObject(),s=this.columnSetFactory.construct(n,i.columns,o),c=this.columnExpansionFactory.construct(n,i.columns,o),u=e.items[t],l={},h=0,p=r;h<p.length;h++){var f=p[h];l[f]=a(u,[f,"links",n])?this.processResponse(e,u[f].links[n],{itemType:t,itemId:f},s,c.run):[]}return this.promiseService.all(l).then(function(e){return{items:e,columns:s,columnExpansion:c.run}},this.errorHandler.reject)},e}(),x=function(){function e(e){this.itemEntryService=e}return e.prototype.processOptions=function(e){return i(e,{edit:!1,onChange:De,onDeactivate:De})},e.prototype.compareOptions=function(e,t){for(var r in e)if(e[r]!==t[r])return!1;return!0},e.prototype.isNew=function(e){return this.itemEntryService.isLocal(e.entry)&&void 0===e.transactions},e}(),M=function(){function e(){this.NEW_PREFIX="-1",this.DUPLICATE_PREFIX="-2",this.NEW_KEYWORD="new-",this.DUPLICATE_KEYWORD="dup-",this.seperator=":"}return e.prototype.getSingleKey=function(e,t){return e.concat(this.seperator,String(t))},e.prototype.getCollectionCacheKey=function(e,t,r){return e.concat(this.seperator,String(t),this.seperator,r)},e.prototype.getCssKey=function(){return Array.prototype.join.call(arguments,"_")},e.prototype.parseStateKey=function(e){return 0===(e=e.toString()).indexOf(this.NEW_KEYWORD)?{type:"new",template:e.substring(this.NEW_KEYWORD.length)}:0===e.indexOf(this.DUPLICATE_KEYWORD)?{type:"duplicate",itemId:e.substring(this.DUPLICATE_KEYWORD.length)}:null},e.prototype.getDuplicateStateKey=function(e){return this.DUPLICATE_KEYWORD.concat(String(e))},e.prototype.getNewStateKey=function(e){return this.NEW_KEYWORD.concat(e)},e.prototype.getLocalId=function(){return parseInt(this.NEW_PREFIX.concat(this.getRandomString()),10)},e.prototype.getLocalDuplicateId=function(){return parseInt(this.DUPLICATE_PREFIX.concat(this.getRandomString()),10)},e.prototype.getRandomString=function(){return Math.random().toString().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 0===e.toString().indexOf(this.NEW_PREFIX)||e===this.NEW_KEYWORD},e.prototype.isDuplicateId=function(e){return 0===e.toString().indexOf(this.DUPLICATE_PREFIX)||e===this.DUPLICATE_KEYWORD},e}(),D=function(){function e(e,t,r,n){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=n,this.lockItems={},this.promises={}}return e.prototype.getValue=function(e,t){var r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]},e.prototype.setValue=function(e,t,r){return u(r,[e.itemType,e.itemId],[{},t])},e.prototype.getLocks=function(){return this.lockItems},e.prototype.hasLock=function(e){for(var t in this.lockItems)for(var r in this.lockItems[t]){var n=this.lockItems[t][r];if(!n.isForeign&&n.id==e)return!0}return!1},e.prototype.isLocked=function(e){var t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign},e.prototype.getMessage=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message},e.prototype.fetchCachedLock=function(e){var t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);var r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()},e.prototype.fetchLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){return void 0!==r?r:t.requestLock(e)},this.errorHandler.reject).then(function(e){return e.isForeign?t.errorHandler.reject(e.message):e.token},this.errorHandler.reject)},e.prototype.requestLock=function(e){var t=this,r=e.itemType,n=e.itemId,i=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:r,item:n}).then(function(i){return delete t.promises[r][n],t.setValue(e,i.fetchObject("Locktoken",i.links.Locktoken[0]),t.lockItems)},function(i){return delete t.promises[r][n],301===i.code?t.setValue(e,{isForeign:!0,message:i.message},t.lockItems):t.errorHandler.reject(i)});return this.setValue(e,i,this.promises)},e.prototype.deleteLock=function(e){var t=this;return this.fetchCachedLock(e).then(function(r){if(void 0!==r){if(!r.isForeign)return t.apiRequestService.delete("Locktoken",r.id).then(function(){t.clearLock(e)},t.errorHandler.reject);t.clearLock(e)}},this.errorHandler.reject)},e.prototype.clearLock=function(e){var t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]},e}(),P=r(1),A=function(){function e(){}return e.prototype.all=function(e){return Object(P.all)(e)},e.prototype.when=function(e){return Object(P.when)(e)},e.prototype.reject=function(e){return Object(P.reject)(e)},e.prototype.defer=function(){return Object(P.defer)()},e}(),L=function(){function e(){}return e.prototype.addAndCondition=function(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}},e.prototype.addOrCondition=function(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}},e.prototype.addParentCondition=function(e,t){var r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))},e.prototype.createNotIn=function(e){return{comparator:"NOT IN",key:"id",value:e}},e}(),_=function(){function e(e,t,r){for(var n in this.promiseService=e,this.getItemId=t,this.getPromise=r,this.entries={},R)this.entries[R[n]]=[]}return e.prototype.add=function(e){var t=e.status;void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e.entry)},e.prototype.hasEntries=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(this.entries[n].length>0)return!0}return!1},e.prototype.hasRequests=function(){return this.hasEntries([R.RESOLVE,R.EXPAND,R.PROMISED_EXPAND])},e.prototype.forEachEntry=function(e,t){for(var r=0,n=e;r<n.length;r++)for(var i=n[r],o=0,s=this.entries[i];o<s.length;o++)t(s[o])},e.prototype.getPromises=function(){var e=this,t=[];return this.forEachEntry([R.PROMISED,R.PROMISED_EXPAND],function(r){t.push(e.getPromise(r))}),this.promiseService.all(t)},e.prototype.getRequestIds=function(){var e=this,t=[];return this.forEachEntry([R.RESOLVE,R.EXPAND,R.PROMISED_EXPAND],function(r){t.push(e.getItemId(r))}),t},e.prototype.getArray=function(){var e=[];for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++){var i=n[r];e.push(i)}return e},e}(),U=function(){function e(e){this.promiseService=e}return e.prototype.construct=function(e,t){return new _(this.promiseService,e,t)},e}(),N=function(){function e(e,t,r,n){this.itemEntryService=e,this.singleItems=t,this.collections=r,this.collectionOptions=n,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.processSingleItems(),this.processCollections(),this.postProcess()}return e.prototype.getParent=function(e){return void 0!==e.parent?e.parent:{itemType:"Void",itemId:0}},e.prototype.addMoveEntry=function(e){this.moveArray.push(e)},e.prototype.addDeleteEntry=function(e,t,r){u(this.deleteMap,[e.itemType,e.itemId],[{},{parentId:t,item:e,parentType:r}])},e.prototype.addUpdateEntry=function(e){u(this.compilation.update,[e.itemType,e.itemId],[{},e])},e.prototype.addCreateEntry=function(e){var t=this.getParent(e);u(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])},e.prototype.postProcess=function(){for(var e=0,t=this.moveArray;e<t.length;e++){var r=(c=t[e]).itemId,n=this.deleteMap[c.itemType];if(void 0!==n&&void 0!==n[r]){var i=c.parent;(s=u(this.compilation.move,[i.itemType,i.itemId],[{},[]])).push(n[r]),delete n[r]}}for(var o in this.deleteMap)for(var r in this.deleteMap[o]){var s,c=this.deleteMap[o][r].item;void 0===(s=this.compilation.delete)[o]&&(s[o]=[]),s[o].push(c)}},e.prototype.processSingleItems=function(){for(var e=0,t=this.singleItems;e<t.length;e++){var r=t[e];this.itemEntryService.isLocal(r)?this.addCreateEntry(r):this.itemEntryService.hasChanges(r)&&this.addUpdateEntry(r)}},e.prototype.isEditableCollection=function(e){return void 0===this.collectionOptions||this.collectionOptions[e.id].edit},e.prototype.hasEditableItems=function(e){return void 0===this.collectionOptions||this.collectionOptions[e.id].editItems},e.prototype.processCollections=function(){for(var e=0,t=this.collections;e<t.length;e++){var r=t[e];if(!r.isDeferred()){var n=r.parent,i=null!==n?n.itemId:0;if(this.isEditableCollection(r)){var o=void 0,s=void 0;r.isLocal()?(o=r.items,s=[]):(o=r.getAddedItems(),s=r.getRemovedItems());for(var c=0,a=o;c<a.length;c++){var u=a[c];this.itemEntryService.isLocal(u)?this.addCreateEntry(u):this.addMoveEntry(u)}for(var l=0,h=s;l<h.length;l++){var p=h[l];this.addDeleteEntry(p,i,n.itemType)}}if(this.hasEditableItems(r))for(var f=0,d=r.getUpdatedItems();f<d.length;f++){var m=d[f];this.addUpdateEntry(m)}}}},e}(),V=function(){function e(e){this.itemEntryService=e}return e.prototype.construct=function(e,t,r){return new N(this.itemEntryService,e,t,r)},e}(),B=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p){this.apiRequestService=e,this.itemHandler=t,this.errorHandler=r,this.collectionHandler=n,this.columnHandler=i,this.changesCompilerFactory=o,this.createRequestFactory=s,this.columnExpansionFactory=c,this.requestColumnExpansionFactory=a,this.collectionEntryService=u,this.itemEntryService=l,this.apiFormatter=h,this.promiseService=p}return e.prototype.getItemTypeUpdatePriority=function(e){switch(e){case"Factuurregelbedrag":return 0;case"Factuurregel":case"Minfactuur":return 1;default:return 2}},e.prototype.buildMoveRequest=function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r].item,o=i.itemType;void 0===t[o]&&(t[o]=[]),t[o].push(i.itemId)}return t},e.prototype.getMapValue=function(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]},e.prototype.execute=function(e,t,r,n,i,o){return void 0===r&&(r=!1),this.executeRequests(this.changesCompilerFactory.construct(e,t,i),n,r,o)},e.prototype.executeCreateRequests=function(e,t,r,n,i){for(var o=[],s=0,c=this.createRequestFactory.construct(e,t,n).run();s<c.length;s++){var a=c[s];o.push(this.executeCreateRequest(a,r).then(u))}return this.promiseService.all(o).then(function(){return r},this.errorHandler.reject);function u(e){return m(i)&&i(r),e}},e.prototype.executeCreateRequest=function(e,t){var r=this;return this.apiRequestService.requestSkeleton(e.request).then(function(n){var i=n.map,o=n.fetchColumnsObject(),s=e.items;for(var c in s){var a=r.columnExpansionFactory.construct(c,e.request.columns[c],o).run;for(var u in s[c]){var l=s[c][u],h=r.getMapValue(c,u,i);if(void 0!==h){r.itemHandler.updateItemId(l,h);var p=n.fetchObject(c,h),f=a(l.columns,!0);r.itemEntryService.updateFields(l,p),null!==f&&r.itemEntryService.expand(l,p,n.fetchDerivedObject(c,h,f.difference.root),f)}else console.warn("Create failed!",l)}}for(var c in r.collectionHandler.addToCollections(e.collections,!0),i)for(var u in void 0===t[c]&&(t[c]={}),i[c])t[c][u]=i[c][u]},this.errorHandler.reject)},e.prototype.prioritizeUpdateRequests=function(e,t){var r=[[],[],[]],n=this.promiseService.when();for(var i in e)r[this.getItemTypeUpdatePriority(i)].push(i);for(var o=0,s=r;o<s.length;o++){var c=s[o];0!==c.length&&(n=n.then(this.executeUpdateRequests(c,e,t),this.errorHandler.reject))}return n},e.prototype.executeUpdateRequests=function(e,t,r){var n=this;return function(){for(var i=[],o=0,s=e;o<s.length;o++){var c=s[o];i.push(n.executeUpdateRequest(c,t[c],r))}return n.promiseService.all(i)}},e.prototype.executeUpdateRequest=function(e,t,r){var n=this,i={},o=this.requestColumnExpansionFactory.construct(),s={};for(var c in i[e]={},t){var a=t[c],u=i[e][c]={},h=l(r,[e,c]);u.values=this.itemEntryService.formatRequest(a),void 0!==h&&(u.parameters=h),o.expand(a.columns),this.collectionHandler.expandCollectionMap(a,s)}for(var p in s){var f=s[p];f.fitting.length>0&&o.expand(f.collection.columns)}return this.apiRequestService.updateItems(e,i,o.get()).then(function(r){var i=n.columnExpansionFactory.construct(e,o.get(),r.fetchColumnsObject());for(var c in t){var a=t[c],u=r.fetchObject(e,c);if(void 0!==u){var l=n.apiFormatter.copyFields(a.initial,{},a.columns.main);n.itemEntryService.setDerived(a,r.fetchDerivedObject(e,c,a.columns.root)),n.itemEntryService.updateFields(a,u),n.itemEntryService.callOnChange(a,l);var h=i.run(a.columns,!0);null!==h&&n.itemEntryService.expand(a,u,r.fetchDerivedObject(e,c,h.difference.root),h)}else console.warn("Update failed!",a)}n.collectionHandler.removeFromAndAddToCollections(s)},this.errorHandler.reject)},e.prototype.executeDeleteRequests=function(e){var t=[];for(var r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)},e.prototype.executeDeleteRequest=function(e,t){for(var r=this,n=[],i=0,o=t;i<o.length;i++){var s=o[i];n.push(s.itemId)}return this.apiRequestService.delete(e,n).then(function(e){for(var n=e.items,i={},o=0,s=t;o<s.length;o++){var a=s[o];c(a.itemId,n)||console.warn("Delete failed!",a),r.collectionHandler.expandCollectionMap(a,i)}r.collectionHandler.removeFromCollections(i,!0)},this.errorHandler.reject)},e.prototype.executeMoveRequests=function(e,t){var r=this,n=[];for(var i in e)for(var o in e[i])s(i,o);return this.promiseService.all(n);function s(i,o){var s=e[i][o],c=this.getMapValue(i,o,t);n.push(r.apiRequestService.moveItems(i,void 0!==c?c:o,this.buildMoveRequest(s)).then(function(e){r.processMoveResponse(e,s)},r.errorHandler.reject))}},e.prototype.processMoveResponse=function(e,t){for(var r=[],n={},i={},o=0,s=t;o<s.length;o++){var c=s[o],a=c.item;this.addCollectionMapEntry(n,c.parentId,a,a.itemId),this.addCollectionMapEntry(i,a.parent.itemId,a,a),r.push(a)}this.forEachCollection(n,"removeItems"),this.forEachCollection(i,"addItems")},e.prototype.addCollectionMapEntry=function(e,t,r,n){u(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(n)},e.prototype.forEachCollection=function(e,t){for(var r in e)for(var n in e[r])for(var i in e[r][n])this.collectionHandler.entries.getByParent(r,n,i)[t](e[r][n][i],null,!0)},e.prototype.onItemsCreated=function(e,t,r){var n=this;if(o(e)){for(var i=0,s=r;i<s.length;i++){var c=s[i],a=c.parent,u=c.getUpdatedItemColumns(e);null!==a&&(void 0!==(p=this.getMapValue(a.itemType,a.itemId,e))&&(a.itemId=p),c.query=this.collectionEntryService.createQuery(c.options)),o(u)&&(void 0!==u.id&&c.onItemsCreated(e[c.itemType]),c.forEach(function(t){n.itemEntryService.updateItemFields(t,e)}))}for(var l=0,h=t;l<h.length;l++){var p,f=h[l],d=f.parent;this.itemEntryService.updateItemFields(f,e),void 0!==d&&void 0!==(p=this.getMapValue(d.itemType,d.itemId,e))&&(d.itemId=p)}}},e.prototype.executeRequests=function(e,t,r,n){var i=this,o=e.compilation,s=e.singleItems,c=e.collections,a={};return this.executeCreateRequests(o.create,t,a,r,n).then(function(){return i.onItemsCreated(a,s,c),i.executeMoveRequests(o.move,a)},function(e){return i.onItemsCreated(a,s,c),i.errorHandler.reject(e)}).then(function(){return i.executeDeleteRequests(o.delete)},this.errorHandler.reject).then(function(){return i.prioritizeUpdateRequests(o.update,t)},this.errorHandler.reject).then(function(){return a},this.errorHandler.reject)},e}(),Q=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.columnHandler=i,this.changesCompilerFactory=o,this.createRequestFactory=s,this.columnExpansionFactory=c,this.requestColumnExpansionFactory=a,this.collectionEntryService=u,this.itemEntryService=l,this.apiFormatter=h,this.promiseService=p}return e.prototype.construct=function(){return new B(this.apiRequestService,this.itemHandler,this.errorHandler,this.collectionHandler,this.columnHandler,this.changesCompilerFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,this.apiFormatter,this.promiseService)},e}();(C||(C={})).MAYBE="maybe";var Y,W,X=function(){function e(e){this.queryMatcherFactory=e,this.entries={}}return e.prototype.contains=function(e){for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++)if(e===n[r])return!0;return!1},e.prototype.some=function(e){for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++)if(e(n[r]))return!0;return!1},e.prototype.forEach=function(e){for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++)e(n[r])},e.prototype.toArray=function(){var e=[];for(var t in this.entries)for(var r=0,n=this.entries[t];r<n.length;r++){var i=n[r];e.push(i)}return e},e.prototype.add=function(e){var t=e.itemType;return void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e),e},e.prototype.clear=function(e){if(void 0===e)return this.entries={},!0;var t=e.itemType;if(void 0===this.entries[t])return!1;var r=this.entries[t].indexOf(e);return-1!==r&&(this.entries[t].splice(r,1),!0)},e.prototype.getByItemType=function(e){return void 0===this.entries[e]?[]:this.entries[e].slice()},e.prototype.getByParent=function(e,t,r){if(void 0===this.entries[r])return null;for(var n=0,i=this.entries[r];n<i.length;n++){var o=i[n];if(o.matchParent(e,t))return o}return null},e.prototype.getResourceByParent=function(e,t,r){var n=this.getByParent(e,t,r);return null===n?null:n.getCurrentResource()},e.prototype.getCollectionsByParent=function(e,t){var r=[];for(var n in this.entries)for(var i=0,o=this.entries[n];i<o.length;i++){var s=o[i];s.matchParent(e,t)&&r.push(s)}return r},e.prototype.getByContainingItem=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n=0,i=this.entries[e];n<i.length;n++){var o=i[n];void 0!==o.getItemById(t)&&r.push(o)}return r},e.prototype.getByFittingItem=function(e,t,r,n){var i=[],o=[],s=[],c={fitting:i,notfitting:s,maybe:o};if(void 0===this.entries[r])return c;for(var a=this.queryMatcherFactory.construct(e,t,n,r),u=0,l=this.entries[r];u<l.length;u++){var h=l[u],p=a.matchQuery(h.query.object);!0===p?i.push(h):p===C.MAYBE?o.push(h):s.push(h)}return c},e.prototype.getByQuery=function(e,t){if(void 0===this.entries[e])return null;for(var r=0,n=this.entries[e];r<n.length;r++){var i=n[r];if(i.query.string===t.string)return i}return null},e.prototype.getByKey=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n=0,i=this.entries[e];n<i.length;n++){var o=i[n];o.options.entryKey===t&&r.push(o)}return r},e.prototype.getResourceByKey=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n=0,i=this.entries[e];n<i.length;n++)for(var o=0,s=i[n].resources;o<s.length;o++){var c=s[o];null!==c&&c.options.resourceKey===t&&r.push(c)}return r},e}(),K=function(){function e(e){this.queryMatcherFactory=e}return e.prototype.construct=function(){return new X(this.queryMatcherFactory)},e}(),J=0,z=function(){function e(e,t,r,n,i,o,s,c,a){this.errorHandler=e,this.collectionEntryService=t,this.itemRequestService=r,this.itemEntryService=n,this.keyService=i,this.queryService=o,this.promiseService=s,this.itemType=c,this.options=a,this.id=J++,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.deferred=this.promiseService.defer(),this.itemType=c,this.options=a,this.query=t.createQuery(a)}return e.prototype.isDeferred=function(){return void 0!==this.promise},e.prototype.resolve=function(e){var t=this.deferred;return this.columns=e.columns,this.initial=e.items,this.items=e.items.slice(),delete this.deferred,delete this.promise,t.resolve(this),this},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.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++)e(r[t])},e.prototype.getItemById=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(n.itemId===e)return n}},e.prototype.getIdArray=function(e){return void 0===e&&(e={}),this.collectionEntryService.getIdArray(this.items,e)},e.prototype.addItems=function(e,t,r,n){if(void 0===r&&(r=!1),void 0===n&&(n=!0),0===e.length)return[];var i=this.resources,o=this.parent,s=this.columns.link;if(r){for(var c=this.initial,a=[],u=0,l=e;u<l.length;u++){var h=l[u];-1===c.indexOf(h)&&(c.push(h),a.push(h))}if(a.length>0)for(var p=0,f=i;p<f.length;p++)(I=f[p]).options.onAddInitial(a,this)}for(var d=this.items,m=[],v=0,y=e;v<y.length;v++)h=y[v],-1===d.indexOf(h)&&(null!==o&&(h.parent=o,null!==s&&void 0!==h.modified&&(h.modified[s.id]=o.itemId)),d.push(h),m.push(h));if(m.length>0){for(var g=void 0,S=0,C=i;S<C.length;S++){var I,E=(I=C[S]).addItemResources(m);I===t?(g=E,n&&I.callOnAdd(E)):I.callOnAdd(E)}return g}return null===t?null:[]},e.prototype.removeItems=function(e,t,r,n){return 0===e.length?[]:this.handleRemovedItems(function(t){return c(t.itemId,e)},t,r,n)},e.prototype.clear=function(e,t,r){return this.handleRemovedItems(function(){return!1},e,t,r)},e.prototype.handleRemovedItems=function(e,t,r,n){void 0===n&&(n=!0);var i,o=this.resources,s=this.collectionEntryService.filterArray(this.items,e),c=r?this.collectionEntryService.filterArray(this.initial,e):[];if(c.length>0)for(var a=0,u=o;a<u.length;a++)(m=u[a]).options.onRemoveInitial(c,this);if(0===s.length)return null===t?null:[];for(var l=0,h=s;l<h.length;l++){var p=h[l];this.itemEntryService.deactivateResources(p)}for(var f=0,d=o;f<d.length;f++){var m,v=(m=d[f]).removeItemResources(s);m===t?(i=v,n&&m.callOnRemove(v)):m.callOnRemove(v)}return i},e.prototype.expand=function(e){var t=this,r=this.itemType;return 0===e.length?this.promiseService.when(this):(this.promise=this.itemRequestService.requestItems(this,void 0,e).then(function(n){var i=n.items[r],o=t.itemRequestService.processExpansion(e,n,r,t.items);return t.handleRemovedItems.call(t,function(e){return void 0!==i[e.itemId]||t.itemEntryService.isLocal(e)},null,!0,!0),t.updateColumns(o),delete t.promise,t},this.errorHandler.reject),this.promise)},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.extend=function(e,t,r,n){var i=this,o=this.extendQuery(e).object,s=this.queryService.addAndCondition(o,this.queryService.createNotIn(this.getIdArray())),c=this.itemRequestService.requestItems(this,null!==this.options.limit?o:s).then(function(e){return i.itemRequestService.processResponse(e,e.links[i.itemType],i.parent,i.columns)},this.errorHandler.reject).then(function(e){return delete i.promise,i.addItems(e,t,n,r)},this.errorHandler.reject);return this.promise=c.then(function(){return i},this.errorHandler.reject),c},e.prototype.queueReload=function(){this.reloadQueued=!0,this.deferred=this.promiseService.defer(),this.promise=this.deferred.promise},e.prototype.updateColumns=function(e){var t=e(this.columns,!1);this.options.columns=t.request,this.columns=t},e.prototype.getAddedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=[],n=0,i=this.items;n<i.length;n++){var o=i[n];-1===t.indexOf(o)&&r.push(e?o.itemId:o)}return r},e.prototype.getRemovedItems=function(e){void 0===e&&(e=!1);for(var t=this.initial,r=this.items,n=[],i=0,o=t;i<o.length;i++){var s=o[i];-1===r.indexOf(s)&&n.push(e?s.itemId:s)}return n},e.prototype.getUpdatedItems=function(){for(var e=[],t=0,r=this.items;t<r.length;t++){var n=r[t];!this.itemEntryService.isLocal(n)&&this.itemEntryService.hasChanges(n)&&e.push(n)}return e},e.prototype.hasAddedItems=function(){return this.items.length>this.initial.length},e.prototype.hasRemovedItems=function(){return this.initial.length>this.items.length},e.prototype.hasUpdatedItems=function(){for(var e=0,t=this.items;e<t.length;e++){var r=t[e];if(this.itemEntryService.hasChanges(r))return!0}return!1},e.prototype.getCurrentResource=function(){var e=this.resources;return e[e.length-1]},e.prototype.clearResources=function(e){void 0===e&&(e=!1);for(var t=this.items,r=this.resources,n=[],i=0,o=t;i<o.length;i++){var s=o[i];this.itemEntryService.clearResources(s)}for(var c=0,a=r;c<a.length;c++){var u=a[c];if(!u.options[e?"clearOnSubTabChange":"clearOnTabChange"]){n.push(u);for(var l=0,h=u.items;l<h.length;l++){var p=h[l];p.entry.resources.push(p)}}}this.resources=n},e.prototype.revertChanges=function(){for(var e=this.resources,t=this.getRemovedItems(),r=this.getAddedItems(!0),n=0,i=e;n<i.length;n++){var o=i[n];o.addItemResources(t),o.removeItemResources(r)}this.items=this.initial.slice()},e.prototype.onItemsCreated=function(e){for(var t=0,r=this.resources;t<r.length;t++){var n=r[t];n.rebuildMap(),n.options.onItemsCreated(e)}},e.prototype.getUpdatedItemColumns=function(e){for(var t={},r=0,n=this.columns.item;r<n.length;r++){var i=n[r];void 0!==e[i.apiColumn.itemType]&&(t[i.id]=i)}return t},e}(),$=function(){function e(e,t,r,n,i,o,s){this.errorHandler=e,this.collectionEntryService=t,this.itemRequestService=r,this.itemEntryService=n,this.keyService=i,this.queryService=o,this.promiseService=s}return e.prototype.construct=function(e,t){return new z(this.errorHandler,this.collectionEntryService,this.itemRequestService,this.itemEntryService,this.keyService,this.queryService,this.promiseService,e,t)},e}(),G=function(){function e(e,t,r){this.itemResourceFactory=e,this.entry=t,this.options=r,this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}return e.prototype.getItemById=function(e){return this.itemIdMap[e]},e.prototype.rebuildMap=function(){for(var e={},t=0,r=this.items;t<r.length;t++){var n=r[t];e[n.entry.itemId]=n}this.itemIdMap=e},e.prototype.addItemResources=function(e){if(0===e.length)return[];for(var t=[],r=this.options,n=this.items,i=this.itemIdMap,o=this.itemResourceFactory.getConstructor({edit:r.editItems,onChange:r.onChange,onDeactivate:r.onDeactivateItem}),s=0,c=e;s<c.length;s++){var a=c[s],u=a.itemId,l=void 0;void 0===i[u]?(l=o(a),n.push(l),i[u]=l):l=i[u],t.push(l)}return t},e.prototype.removeItemResources=function(e){var t=this,r=[];return function(e,t){for(var r=[],n=0,i=e;n<i.length;n++){var o=i[n];t(o)&&r.push(o)}if(r.length===e.length)return!1;e.splice(0);for(var s=0,c=r;s<c.length;s++){var a=c[s];e.push(a)}}(this.items,function(n){for(var i=0,o=e;i<o.length;i++){var s=o[i];if(n.entry===s)return r.push(n),delete t.itemIdMap[s.itemId],!1}return!0}),r},e.prototype.callOnAdd=function(e){this.options.onAdd(e,this)},e.prototype.callOnRemove=function(e){this.options.onRemove(e,this)},e.prototype.forEach=function(e){for(var t=0,r=this.items;t<r.length;t++)e(r[t])},e.prototype.filter=function(e){for(var t=[],r=0,n=this.items;r<n.length;r++){var i=n[r];e(i)&&t.push(i)}return t},e.prototype.first=function(e){for(var t=0,r=this.items;t<r.length;t++){var n=r[t];if(e(n))return n}return null},e.prototype.some=function(e){return null!==this.first(e)},e.prototype.groupBy=function(e){var t=this.items,r={};if("string"==typeof e)for(var n=0,i=t;n<i.length;n++)void 0===r[a=(c=i[n]).fields[e]]&&(r[a]=[]),r[a].push(c);if("function"==typeof e)for(var o=0,s=t;o<s.length;o++){var c,a;null!==(a=e(c=s[o]))&&(void 0===r[a]&&(r[a]=[]),r[a].push(c))}return r},e.prototype.map=function(e){var t=this.items,r=t.length,n=new Array(r);if("string"==typeof e)for(var i=0;i<r;i++)n[i]=t[i].fields[e];if("function"==typeof e)for(i=0;i<r;i++)n[i]=e(t[i]);return n},e.prototype.reduce=function(e,t){for(var r=0,n=this.items;r<n.length;r++)t=e(n[r],t);return t},e.prototype.extend=function(e,t,r){var n=this;return void 0===r&&(r=!0),this.entry.extend(e,this,r).then(function(e){return t?n.items:e})},e.prototype.deactivate=function(){this.options.onDeactivateCollection(this)},e.prototype.clearResource=function(){var e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(var n=0,i=t;n<i.length;n++)i[n].clearResource()},e}(),Z=(Y=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])},function(e,t){function r(){this.constructor=e}Y(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),ee=function(e){function t(t,r,n,i,o,s,c,a){var u=e.call(this,n,c,a)||this;return u.errorHandler=t,u.itemHandler=r,u.changesProcessorFactory=i,u.keyService=o,u.promiseService=s,u}return Z(t,e),t.prototype.save=function(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");var e=this.entry,t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)?this.promiseService.when():this.changesProcessorFactory.construct().execute([],[e])},t.prototype.moveItems=function(e,t,r){var n=this.entry,i=this.options;if(i.enableSave||i.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(n.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");for(var o=n.removeItems(e,this,!1,r),s=[],c=0,a=o;c<a.length;c++){var u=a[c];s.push(u.entry)}return t.entry.addItems(s,t,!1,r),o},t.prototype.removeItems=function(e,t){var r=this;void 0===t&&(t=!0);var n=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(function(){return t&&r.callOnRemove(n),n}):(t&&this.callOnRemove(n),this.promiseService.when(n))},t.prototype.removeItem=function(e,t){return this.removeItems([e],t).then(function(e){return e[0]},this.errorHandler.reject)},t.prototype.addItems=function(e,t){var r=this;return void 0===t&&(t=!0),this.itemHandler.fetchTemplate(this.entry.itemType).then(function(n){for(var i,o=[],s=0,c=e;s<c.length;s++){var a=c[s];o.push(r.itemHandler.createLocalEntry(r.keyService.getLocalId(),n,a.fields,a.derived))}return i=r.entry.addItems(o,self,!1,!1),r.options.modInstant?r.save().then(function(e){return t&&r.callOnAdd(i),i},r.errorHandler.reject):(t&&r.callOnAdd(i),i)},this.errorHandler.reject)},t.prototype.addItem=function(e,t){return this.addItems([e],t).then(function(e){return e[0]},this.errorHandler.reject)},t.prototype.clear=function(e){return this.entry.clear(this,!1,e)},t}(G),te=function(){var 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])};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)}}(),re=function(e){function t(t,r,n,i,o,s,c,a){var u=e.call(this,n,c,a)||this;return u.errorHandler=t,u.itemHandler=r,u.changesProcessorFactory=i,u.keyService=o,u.promiseService=s,u}return te(t,e),t}(G),ne=function(){function e(e,t,r,n,i,o){this.errorHandler=e,this.itemHandler=t,this.itemResourceFactory=r,this.changesProcessorFactory=n,this.keyService=i,this.promiseService=o}return e.prototype.construct=function(e,t){return new(t.editCollection?ee:re)(this.errorHandler,this.itemHandler,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,this.promiseService,e,t)},e}(),ie=function(){function e(e,t,r,n,i,o){if(this.columnHandler=e,this.columnSetFactory=t,this.columnUtil=r,this.itemType=n,this.requestColumns=i,this.responseColumns=o,this.expansionMap={},!0===i)for(var s in this.requestColumnsTrue=!0,this.requestColumns=[],o[n])this.requestColumns.push(s);else this.requestColumnsTrue=!1}return e.prototype.run=function(e,t){var r=e.id;return void 0!==this.expansionMap[r]?t?this.expansionMap[r]:this.expansionMap[r].merged:this.columnUtil.isColumnSubset(this.requestColumns,e.request,e.true)?t?null:e:(this.expansionMap[r]=this.expandColumnInfo(e),t?this.expansionMap[r]:this.expansionMap[r].merged)},e.prototype.expandColumnInfo=function(e){var t=this.columnUtil.mergeRequestColumns(e.request,this.requestColumns),r=this.columnUtil.mergeResponseColumns(e.response,this.responseColumns).merged,n=this.columnSetFactory.construct(this.itemType,t.merged,r),i=this.columnSetFactory.construct(this.itemType,t.difference,r,!1,!1);return n.true=this.requestColumnsTrue||e.true,{merged:n,difference:i}},e}(),oe=function(){function e(e,t,r){this.columnHandler=e,this.columnSetFactory=t,this.columnUtil=r}return e.prototype.construct=function(e,t,r){return new ie(this.columnHandler,this.columnSetFactory,this.columnUtil,e,t,r)},e}(),se=0,ce=function(){function e(e,t,r,n,i,o,s){void 0===o&&(o=!0),void 0===s&&(s=!0),this.columnHandler=e,this.columnUtil=t,this.itemType=r,this.requestColumns=n,this.responseColumns=i,this.enableCaching=o,this.includeIdColumn=s,this.id=++se,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.request=[],this.response={},this.true=!0===n,!0===n?this.processResponseColumns():this.processRequestColumns()}return e.prototype.processResponseColumns=function(){for(var e in this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,this.responseColumns):this.responseColumns,this.responseColumns[this.itemType])this.main.push(this.getColumnInfo(this.responseColumns[this.itemType][e],[],null)),this.request.push(e)},e.prototype.processRequestColumns=function(){if(this.request=this.requestColumns,this.response={},0!==this.requestColumns.length){for(var e=0,t=this.requestColumns;e<t.length;e++){var r=t[e],n=this.getRequestColumnInfo(r,this.itemType,null);null!==n&&(this.main.push(n),n.isLeaf||this.root.push(n))}this.includeIdColumn&&void 0===this.response[this.itemType].id&&this.main.push(this.getRequestColumnInfo("id",this.itemType,null))}},e.prototype.getRequestColumnInfo=function(e,t,r){var n,i=this.columnUtil.parseRequestColumn(e),o=i.id;if(void 0!==this.responseColumns[t]&&(n=this.responseColumns[t][o]),void 0===n)return console.warn("No api column for request column",o,"for itemType",t),null;this.enableCaching&&(n=this.columnHandler.setColumn(t,n));var s=this.response;return void 0===s[t]&&(s[t]={}),void 0===s[t][o]&&(s[t][o]=n),this.getColumnInfo(n,i.children,r)},e.prototype.getColumnInfo=function(e,t,r){var n=null!==r,i=e.id,o={id:i,path:n?r.path.concat(">",i):i,apiColumn:e,level:n?r.level+1:0,isLeaf:0===t.length,itemType:"",children:[],parent:null,tailPath:null};if(n?(this.derived.push(o),o.parent=r,o.tailPath=r.level>0?r.tailPath.concat(">",i):i):this[this.columnUtil.isItemColumn(e)?"item":"notItem"].push(o),this.columnUtil.isFormattedColumn(e)&&this.formatted[n?"derived":"main"].push(o),this.columnUtil.isFilteredColumn(e)&&this.filtered.push(o),this.columnUtil.isSearchableColumn(e)&&this.searchable.push(o),this.columnUtil.isCustomColumn(e)&&this.custom.push(o),"link"===e.type&&(this.link=e),0===t.length)return this.leaf.push(o),o;void 0===e.itemType&&console.warn("itemType undefined in column",e),o.itemType=e.itemType,o.children=[];for(var s=0,c=t;s<c.length;s++){var a=c[s],u=this.getRequestColumnInfo(a,o.itemType,o);null!==u&&o.children.push(u)}return o},e}(),ae=function(){function e(e,t){this.columnHandler=e,this.columnUtil=t}return e.prototype.construct=function(e,t,r,n,i){return void 0===n&&(n=!0),void 0===i&&(i=!0),new ce(this.columnHandler,this.columnUtil,e,t,r,n,i)},e}(),ue=function(){function e(e,t,r,n,i,o,s){void 0===s&&(s=!1),this.collectionHandler=e,this.requestColumnExpansionFactory=t,this.itemEntryService=r,this.keyService=n,this.compilation=i,this.parameterMap=o,this.breakupByParent=s,this.requests=[]}return e.prototype.finalizeRequest=function(e){var t=e.collections,r=e.columns;for(var n in t){var i=t[n];i.fitting.length>0&&r.expand(i.collection.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(){if(this.breakupByParent)for(var e in this.compilation){var t=this.compilation[e];for(var r in t)if(!this.keyService.isLocalId(r)){var n=this.initializeRequest();this.extendRequest(t[r],this.setRequestParent(e,n)?r:null,n),this.requests.push(this.finalizeRequest(n))}}else for(var e in this.compilation){t=this.compilation[e],n=this.initializeRequest();var i=this.setRequestParent(e,n),o=!1;for(var r in t)this.keyService.isLocalId(r)||(this.extendRequest(t[r],i?r:null,n),o=!0);o&&this.requests.push(this.finalizeRequest(n))}return this.requests},e.prototype.initializeRequest=function(){return{request:{requestType:"create",items:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:{}}},e.prototype.extendRequest=function(e,t,r){var n=r.request,i=r.items;for(var o in e)for(var s in void 0===n.itemType&&(n.itemType=o),void 0===i[o]&&(i[o]={},n.items[o]={}),e[o]){var c=e[o][s],a=l(this.compilation,[o,s]),u=n.items[o][s]={},h=l(this.parameterMap,[o,s]),p=void 0;if(null!==t&&(n.parentId[s]=t),r.columns.expand(c.columns),this.collectionHandler.expandCollectionMap(c,r.collections),i[o][s]=c,u.values=this.itemEntryService.formatRequest(c),u.parameters=h,void 0!==a){for(var f in p=u.links={},a)for(var d in p[f]=[],a[f])p[f].push(d);this.extendRequest(a,null,r)}}},e}(),le=function(){function e(e,t,r,n){this.collectionHandler=e,this.requestColumnExpansionFactory=t,this.itemEntryService=r,this.keyService=n}return e.prototype.construct=function(e,t,r){return void 0===r&&(r=!1),new ue(this.collectionHandler,this.requestColumnExpansionFactory,this.itemEntryService,this.keyService,e,t,r)},e}(),he=function(){function e(e,t){this.queryMatcherFactory=e,this.itemEntryService=t,this.entries={}}return e.prototype.some=function(e){for(var t in this.entries)for(var r in this.entries[t])if(e(this.entries[t][r]))return!0;return!1},e.prototype.getByItemType=function(e){var t=[];if(void 0===this.entries[e])return t;for(var r in this.entries[e])t.push(this.entries[e][r]);return t},e.prototype.getByQuery=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n in this.entries[e]){var i=this.entries[e][n];this.matchQuery(i,t)&&r.push(i)}return r},e.prototype.getLocalByQuery=function(e,t){var r=[];if(void 0===this.entries[e])return r;for(var n in this.entries[e]){var i=this.entries[e][n];this.itemEntryService.isLocal(i)&&this.matchQuery(i,t)&&r.push(i)}return r},e.prototype.forEach=function(e){for(var t in this.entries)for(var r in this.entries[t])e(this.entries[t][r])},e.prototype.toArray=function(){var e=[];for(var t in this.entries)for(var r in this.entries[t])e.push(this.entries[t][r]);return e},e.prototype.add=function(e){var t=e.itemType;return void 0===this.entries[t]&&(this.entries[t]={}),this.entries[t][e.itemId]=e},e.prototype.get=function(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]},e.prototype.getByParent=function(e,t,r){var n=[];if(void 0===this.entries[r])return n;for(var i in this.entries[r]){var o=this.entries[r][i],s=o.parent;void 0!==s&&e===s.itemType&&t==s.itemId&&n.push(o)}return n},e.prototype.contains=function(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]},e.prototype.updateItemId=function(e,t){var r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e},e.prototype.clear=function(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]},e.prototype.matchQuery=function(e,t){var r=void 0!==e.parent?e.parent:{};return!0===this.queryMatcherFactory.construct(r.itemType,r.itemId,this.itemEntryService.getFields(e)).matchQuery(t.object)},e}(),pe=function(){function e(e,t){this.queryMatcherFactory=e,this.itemEntryService=t}return e.prototype.construct=function(){return new he(this.queryMatcherFactory,this.itemEntryService)},e}(),fe=0,de=function(e,t,r,n,i,o){void 0===n&&(n={}),void 0===i&&(i={}),void 0===o&&(o=[]),this.itemType=e,this.itemId=t,this.columns=r,this.initial=n,this.derived=i,this.resources=o,this.parent=null,this.deferRequest=!1,this.entryId=++fe},me=function(){function e(){}return e.prototype.construct=function(e,t,r,n,i,o){return void 0===n&&(n={}),void 0===i&&(i={}),void 0===o&&(o=[]),new de(e,t,r,n,i,o)},e}(),ve=function(){function e(e,t,r){this.itemEntryService=e,this.entry=t,this.options=r,this.derived=t.derived,this.columns=t.columns.response[t.columns.itemType],t.resources.push(this)}return e.prototype.isLocal=function(){return this.itemEntryService.isLocal(this.entry)},e.prototype.clearResource=function(){var e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)},e.prototype.deactivate=function(){this.options.onDeactivate(this)},e}(),ye=function(){var 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])};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)}}(),ge=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return t.setModified(r),i.fields=r.modified,i}return ye(t,e),t}(ve),Se=function(){var 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])};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(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.fields=void 0===r.modified?r.initial:r.modified,i}return Se(t,e),t}(ve),Ie=function(){function e(e,t){this.itemEntryService=e,this.itemResourceService=t}return e.prototype.getConstructor=function(e){var t=this,r=(e=this.itemResourceService.processOptions(e)).edit?ge:Ce;return function(n){return new r(t.itemEntryService,n,e)}},e.prototype.construct=function(e,t){return new(t.edit?ge:Ce)(this.itemEntryService,e,t)},e}(),Ee={},Re=function(){function e(e,t,r,n){this.itemEntryService=e,this.rootItemEntry=t,this.singleItemCache=r,this.collectionCache=n}return e.prototype.process=function(){this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{})},e.prototype.createParentMap=function(e){var t={};return e.forEach(function(e){var r=e.itemType,n=e.parent;if(void 0!==n){var i=n.itemType,o=n.itemId;void 0===t[i]&&(t[i]={});var s=t[i];void 0===s[o]&&(s[o]={}),void 0===(s=s[o])[r]&&(s[r]=[]),s[r].push(e)}}),t},e.prototype.processItems=function(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(var n=0,i=t;n<i.length;n++){var o=i[n],s=o.itemId;void 0===this.destination[e][s]&&(r[e].push(s),this.destination[e][s]=this.processItem(o))}},e.prototype.processItem=function(e){var t=e.itemType,r=e.itemId,n=this.getItemsByParent(t,r),i=this.collectionCache.getCollectionsByParent(t,r),s=this.itemEntryService.formatRequest(e),c={};for(var a in n)this.processItems(a,n[a],c);for(var u=0,l=i;u<l.length;u++){var h=l[u];null===h.options.query&&this.processItems(h.itemType,h.items,c)}var p=o(s),f=o(c);return p&&f?{values:s,links:c}:p?{values:s}:f?{links:c}:Ee},e.prototype.getItemsByParent=function(e,t){var r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]},e}(),qe=function(){function e(e){this.itemEntryService=e}return e.prototype.construct=function(e,t,r){return new Re(this.itemEntryService,e,t,r)},e}(),Te="maybe",be=function(){function e(e,t,r,n,i){this.apiFormatter=e,this.parentType=t,this.parentId=r,this.fields=n,this.itemType=i}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 Te;if(void 0!==e.custom)return Te;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!o(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")},e.prototype.matchLinkedToQuery=function(e){return e.reverse?Te:(t=e.linkedTo===this.parentType&&this.matchSimpleQuery(this.parentId,e.query))===Te?Te:e.not?!t:t;var 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 i=0,o=n;i<o.length;i++){var s=o[i],c=this.matchQuery(s);if(c===r)return r;c===Te&&(t=Te)}return t},e.prototype.matchSimpleQuery=function(e,t){var r=t.key,i=t.value;if(!o(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),Te;switch("NOW"===i&&(i=n()),t.comparator){case"=":return this.compareValues(e,i);case"!=":return!this.compareValues(e,i);case"<":return e<i;case"<=":return e<=i;case">":return e>i;case">=":return e>=i;case"IN":return c(e,i);case"NOT IN":return!c(e,i);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}},e}(),Fe=function(){function e(e){this.apiFormatter=e}return e.prototype.construct=function(e,t,r,n){return new be(this.apiFormatter,e,t,r,n)},e}();!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(W||(W={}));var ke=function(){function e(e,t){this.query=e,this.parameters=t}return e.prototype.processValue=function(e){return Array.isArray(e)?e.slice().sort():n.isMoment(e)?n(e):n.isDuration(e)?n.duration(e):e},e.prototype.compareParsedQueries=function(e,t){return e[W.STR]===t[W.STR]?0:e[W.STR]>t[W.STR]?1:-1},e.prototype.parse=function(e){if(void 0===e&&(e=this.query),void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);if(!o(e))return[{},"{}"];var t=s(e);return this.parseSimpleQuery(t,e[t])},e.prototype.parseSearchQuery=function(e){return[{search:(e=this.formatValue(e))[W.OBJ]},"[search"+W.SEP+e[W.STR]+"]"]},e.prototype.parseCustomQuery=function(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];var r=this.parseCustomParameters(t);return[{custom:e,parameters:r[W.OBJ]},"["+e+W.SEP+r[W.STR]+"]"]},e.prototype.parseCustomParameters=function(e){for(var t=Object.keys(e).sort(),r={},n="",i=0;i<t.length;i++){var o=t[i],s=this.formatValue(e[o]);r[o]=s[W.OBJ],i>0&&(n+=W.SEP),n+=s[W.STR]}return[r,n]},e.prototype.parseSimpleQuery=function(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[W.OBJ])?"IN":"="),[{key:e,value:t[W.OBJ],comparator:r},"["+r+W.SEP+e+W.SEP+t[W.STR]+"]"]},e.prototype.parseLinkedToQuery=function(e,t,r,n){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!1);var i=this.parse(t);return[{linkedTo:e,query:i[W.OBJ],reverse:r,not:n},"[linkedTo"+W.SEP+e+W.SEP+i[W.STR]+W.SEP+r+W.SEP+n+"]"]},e.prototype.parseComplexQuery=function(e,t){t=void 0===t?"AND":t.toUpperCase();var r=this.parseConditions(e);return[{conditions:r[W.OBJ],operator:t},"["+t+r[W.STR]+"]"]},e.prototype.parseConditions=function(e){for(var t=[],r=[],n="",i=0,o=e;i<o.length;i++){var s=o[i];t.push(this.parse(s))}for(var c=0,a=t=t.sort(this.compareParsedQueries);c<a.length;c++){var u=a[c];r.push(u[W.OBJ]),n+=u[W.STR]}return[r,n]},e.prototype.formatValue=function(e){var t;if("string"==typeof e&&"&"===e.charAt(0)){var r=e.substring(1);if(void 0===(e=this.parameters[r]))throw new Error("queryParser: Undefined template parameter '"+r+"'");return[t=this.processValue(e),r+">"+e]}return[t=this.processValue(e),""+t]},e}(),we=function(){function e(){}return e.prototype.construct=function(e,t){return new ke(e,t)},e}(),Oe=function(){function e(e){this.columnUtil=e,this.columns={},this.columnInfoIdMap={}}return e.prototype.expand=function(e){if(!this.columnInfoIdMap[e.id]){var t=e.itemType;void 0===this.columns[t]&&(this.columns[t]=[]),this.columns[t]=this.columnUtil.mergeRequestColumns(this.columns[t],e.request).merged,this.columnInfoIdMap[e.id]=!0}},e.prototype.get=function(){return this.columns},e}(),je=function(){function e(e){this.columnUtil=e}return e.prototype.construct=function(){return new Oe(this.columnUtil)},e}(),He=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.columnHandler=i,this.lockService=o,this.itemResourceFactory=s,this.collectionCacheFactory=c,this.changesProcessorFactory=a,this.itemCacheFactory=u,this.collectionResourceFactory=l,this.itemEntryService=h,this.itemResourceService=p,this.promiseService=f,this.collectionOptions={},this.tabRequestParameters={},this.callbacks={onBeforeSave:{},onSaveSuccess:{},onSaveWithoutClosing:{}},this._hasChanges=!1,this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct(),this.items=this.itemCacheFactory.construct()}return e.prototype.addSingleItem=function(e,t,r){return r&&(this.rootItem=e),this.items.contains(e.itemType,e.itemId)||this.items.add(e),(t=this.itemResourceService.processOptions(t)).onDeactivate=this.clearItem,this.itemResourceFactory.construct(e,t)},e.prototype.addCollection=function(e,t){this.collections.contains(e)||this.collections.add(e);var r=e.id;if(void 0===this.collectionOptions[r])this.collectionOptions[r]={edit:t.editCollection,editItems:t.editItems};else{var n=this.collectionOptions[r];n.edit=n.edit||t.editCollection,n.editItems=n.editItems||t.editItems}return t.onDeactivateItem=this.clearItem,t.onDeactivateCollection=this.clearCollection,this.collectionResourceFactory.construct(e,t)},e.prototype.clearCollection=function(e){var t=e.entry;this.collections.clear(t),t.clearResources()},e.prototype.clearItem=function(e){var t=e.entry;this.items.clear(t),this.itemEntryService.clearResources(t)},e.prototype.clearResources=function(e){void 0===e&&(e=!1),this.items.forEach(this.itemEntryService.clearResources),this.collections.forEach(function(t){t.clearResources(e)}),e||this.collections.clear()},e.prototype.updateSingleItems=function(e){for(var t in e)for(var r in e[t]){var n=this.items.get(t,r);void 0!==n&&this.items.updateItemId(n,r)}},e.prototype.revertChanges=function(){this.items.forEach(this.itemEntryService.resetModified),this.collections.forEach(this.resetCollection)},e.prototype.resetCollection=function(e){var t=this.collectionOptions[e.id];if(t.edit&&e.revertChanges(),t.editItems)for(var r=0,n=e.items;r<n.length;r++){var i=n[r];this.itemEntryService.resetModified(i)}},e.prototype.hasChanges=function(){return this._hasChanges||(this._hasChanges=this.detectChanges()),this._hasChanges},e.prototype.detectChanges=function(){var e=this;return!!this.items.some(this.itemEntryService.hasChanges)||this.collections.some(function(t){e.collectionHasChanges(t)})},e.prototype.collectionHasChanges=function(e){var t=this.collectionOptions[e.id];return!(!t.edit||!e.hasAddedItems()&&!e.hasRemovedItems())||t.editItems&&e.hasUpdatedItems()},e.prototype.isLockable=function(){return void 0!==this.rootItem&&this.itemEntryService.isLockable(this.rootItem)},e.prototype.save=function(e,t,r,n){var i=this;return void 0===e&&(e=!1),(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(function(t){return i.executeCallbacks("onBeforeSave",e)},this.errorHandler.reject).then(function(){var e=h({},i.tabRequestParameters,t);return i.tabRequestParameters={},i.changesProcessorFactory.construct().execute(i.items.toArray(),i.collections.toArray(),r,e,i.collectionOptions,n)},this.errorHandler.reject).then(function(t){return i.isLockable()&&i.lockService.clearLock(i.rootItem),i._hasChanges=!1,e||i.updateSingleItems(t),i.executeCallbacks("onSaveSuccess",t).then(function(){return e||i.executeCallbacks("onSaveWithoutClosing",t),t},i.errorHandler.reject)},this.errorHandler.reject)},e.prototype.executeCallbacks=function(e,t){var r={};for(var n in this.callbacks[e])r[n]=this.callbacks[e][n](t);return this.promiseService.all(r)},e.prototype.enableChangesWatcher=function(){var e=this;null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(function(){e.hasChanges()&&(e.disableChangesWatcher(),e.isLockable()&&e.lockService.fetchLock(e.rootItem))},3e3)},e.prototype.enableWatcher=function(){this.enableChangesWatcher()},e.prototype.disableChangesWatcher=function(){clearInterval(this.changesInterval),this.changesInterval=null},e.prototype.disableWatcher=function(){this.disableChangesWatcher()},e.prototype.registerCallback=function(e,t,r){var n=this;return this.callbacks[e][t]=r,function(){delete n.callbacks[e][t]}},e}(),xe=function(){function e(e,t,r,n,i,o,s,c,a,u,l,h,p,f){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=n,this.columnHandler=i,this.lockService=o,this.itemResourceFactory=s,this.collectionCacheFactory=c,this.changesProcessorFactory=a,this.itemCacheFactory=u,this.collectionResourceFactory=l,this.itemEntryService=h,this.itemResourceService=p,this.promiseService=f}return e.prototype.construct=function(){return new He(this.apiRequestService,this.errorHandler,this.itemHandler,this.collectionHandler,this.columnHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemEntryService,this.itemResourceService,this.promiseService)},e}();r.d(t,"noop",function(){return De}),r.d(t,"identity",function(){return Pe}),r.d(t,"ViewResource",function(){return Ce}),r.d(t,"EditResource",function(){return ge}),r.d(t,"ENTRY_STATUS",function(){return R}),r.d(t,"COLUMN_SEPERATOR",function(){return">"}),r.d(t,"RENDER_AS_SEPERATOR",function(){return":"});var Me=function(e,t,r,n){this.promiseService=new A,this.apiFormatter=new I,this.keyService=new M,this.queryService=new L,this.columnUtil=new k,this.itemEntryService=new O(this.apiFormatter,this.keyService,this.promiseService),this.itemResourceService=new x(this.itemEntryService),this.lockService=new D(e,n,this.keyService,this.promiseService),this.queryMatcherFactory=new Fe(this.apiFormatter),this.itemCacheFactory=new pe(this.queryMatcherFactory,this.itemEntryService),this.batchStatusFactory=new U(this.promiseService),this.columnCache=new b(this.columnUtil),this.columnHandler=new F(e,n,this.promiseService,this.columnCache,this.columnUtil),this.columnSetFactory=new ae(this.columnHandler,this.columnUtil),this.columnExpansionFactory=new oe(this.columnHandler,this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new me,this.itemHandler=new j(e,r,n,this.itemEntryFactory,this.columnHandler,this.itemCacheFactory,this.batchStatusFactory,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryService,this.apiFormatter,this.keyService,this.promiseService,this.columnUtil),this.itemRequestService=new H(e,n,this.itemHandler,this.columnHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryService,this.queryService,this.promiseService),this.queryParserFactory=new we,this.collectionEntryService=new E(this.queryParserFactory,this.queryService),this.collectionResourceService=new T,this.collectionEntryFactory=new $(n,this.collectionEntryService,this.itemRequestService,this.itemEntryService,this.keyService,this.queryService,this.promiseService),this.collectionCacheFactory=new K(this.queryMatcherFactory),this.collectionHandler=new q(n,this.itemRequestService,this.itemHandler,this.columnHandler,this.collectionEntryFactory,this.collectionCacheFactory,this.queryParserFactory,this.collectionEntryService,this.columnSetFactory,this.itemEntryService,this.keyService,this.promiseService,this.queryService,this.columnUtil),this.requestColumnExpansionFactory=new je(this.columnUtil),this.createRequestFactory=new le(this.collectionHandler,this.requestColumnExpansionFactory,this.itemEntryService,this.keyService),this.changesCompilerFactory=new V(this.itemEntryService),this.changesProcessorFactory=new Q(e,n,this.itemHandler,this.collectionHandler,this.columnHandler,this.changesCompilerFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,this.apiFormatter,this.promiseService),this.itemResourceFactory=new Ie(this.itemEntryService,this.itemResourceService),this.collectionResourceFactory=new ne(n,this.itemHandler,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,this.promiseService),this.resourceCacheFactory=new xe(e,n,this.itemHandler,this.collectionHandler,this.columnHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemEntryService,this.itemResourceService,this.promiseService),this.moduleChangesCompilerFactory=new qe(this.itemEntryService),this.itemAdministrator=new w(e,t,r,n,this.itemHandler,this.collectionHandler,this.columnSetFactory,this.itemRequestService,this.resourceCacheFactory,this.moduleChangesCompilerFactory,this.collectionEntryService,this.collectionResourceService,this.itemEntryService,this.keyService,this.queryService)};function De(){}function Pe(e){return e}t.default=Me},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,s,c,a=1,u={},l=!1,h=e.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(e);p=p&&p.setTimeout?p:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){d(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?(s="setImmediate$"+Math.random()+"$",c=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&d(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",c,!1):e.attachEvent("onmessage",c),n=function(t){e.postMessage(s+t,"*")}):e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){d(e.data)},n=function(e){o.port2.postMessage(e)}):h&&"onreadystatechange"in h.createElement("script")?(i=h.documentElement,n=function(e){var t=h.createElement("script");t.onreadystatechange=function(){d(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(d,0,e)},p.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var i={callback:e,args:t};return u[a]=i,n(a),a++},p.clearImmediate=f}function f(e){delete u[e]}function d(e){if(l)setTimeout(d,0,e);else{var t=u[e];if(t){l=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(r,n)}}(t)}finally{f(e),l=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,r(2),r(3))},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(2))}])});
28
+ !function(t){"use strict";"function"==typeof bootstrap?bootstrap("promise",t):e.exports=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var i,n=R(),s=function(){},o=function(){var e={task:void 0,next:null},i=e,n=!1,s=void 0,c=!1,a=[];function u(){for(var t,r;e.next;)t=(e=e.next).task,e.task=void 0,(r=e.domain)&&(e.domain=void 0,r.enter()),l(t,r);for(;a.length;)l(t=a.pop());n=!1}function l(e,t){try{e()}catch(e){if(c)throw t&&t.exit(),setTimeout(u,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}if(o=function(e){i=i.next={task:e,domain:c&&t.domain,next:null},n||(n=!0,s())},"object"==typeof t&&"[object process]"===t.toString()&&t.nextTick)c=!0,s=function(){t.nextTick(u)};else if("function"==typeof r)s="undefined"!=typeof window?r.bind(window,u):function(){r(u)};else if("undefined"!=typeof MessageChannel){var h=new MessageChannel;h.port1.onmessage=function(){s=m,h.port1.onmessage=u,u()};var m=function(){h.port2.postMessage(0)};s=function(){setTimeout(u,0),m()}}else s=function(){setTimeout(u,0)};return o.runAfter=function(e){a.push(e),n||(n=!0,s())},o}(),c=Function.call;function a(e){return function(){return c.apply(e,arguments)}}var u,l=a(Array.prototype.slice),h=a(Array.prototype.reduce||function(e,t){var r=0,i=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=i)throw new TypeError}for(;r<i;r++)r in this&&(t=e(t,this[r],r));return t}),m=a(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),d=a(Array.prototype.map||function(e,t){var r=this,i=[];return h(r,function(n,s,o){i.push(e.call(t,s,o,r))},void 0),i}),p=Object.create||function(e){function t(){}return t.prototype=e,new t},f=Object.defineProperty||function(e,t,r){return e[t]=r.value,e},y=a(Object.prototype.hasOwnProperty),v=Object.keys||function(e){var t=[];for(var r in e)y(e,r)&&t.push(r);return t},g=a(Object.prototype.toString);u="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e};var S="From previous event:";function C(t,r){if(e&&r.stack&&"object"==typeof t&&null!==t&&t.stack){for(var i=[],n=r;n;n=n.source)n.stack&&(!t.__minimumStackCounter__||t.__minimumStackCounter__>n.stackCounter)&&(f(t,"__minimumStackCounter__",{value:n.stackCounter,configurable:!0}),i.unshift(n.stack));i.unshift(t.stack);var s=function(e){for(var t=e.split("\n"),r=[],i=0;i<t.length;++i){var n=t[i];!E(n)&&-1===(s=n).indexOf("(module.js:")&&-1===s.indexOf("(node.js:")&&n&&r.push(n)}var s;return r.join("\n")}(i.join("\n"+S+"\n"));f(t,"stack",{value:s,configurable:!0})}}function I(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);if(t)return[t[1],Number(t[2])];var r=/at ([^ ]+):(\d+):(?:\d+)$/.exec(e);if(r)return[r[1],Number(r[2])];var i=/.*@(.+):(\d+)$/.exec(e);return i?[i[1],Number(i[2])]:void 0}function E(e){var t=I(e);if(!t)return!1;var r=t[0],s=t[1];return r===i&&s>=n&&s<=J}function R(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),r=I(t[0].indexOf("@")>0?t[1]:t[2]);if(!r)return;return i=r[0],r[1]}}function q(e){return e instanceof w?e:x(e)?(t=e,r=F(),q.nextTick(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):B(e);var t,r}q.resolve=q,q.nextTick=o,q.longStackSupport=!1;var T=1;function F(){var t,r=[],i=[],n=p(F.prototype),s=p(w.prototype);if(s.promiseDispatch=function(e,n,s){var o=l(arguments);r?(r.push(o),"when"===n&&s[1]&&i.push(s[1])):q.nextTick(function(){t.promiseDispatch.apply(t,o)})},s.valueOf=function(){if(r)return s;var e=j(t);return H(e)&&(t=e),e},s.inspect=function(){return t?t.inspect():{state:"pending"}},q.longStackSupport&&e)try{throw new Error}catch(e){s.stack=e.stack.substring(e.stack.indexOf("\n")+1),s.stackCounter=T++}function o(n){t=n,q.longStackSupport&&e&&(s.source=n),h(r,function(e,t){q.nextTick(function(){n.promiseDispatch.apply(n,t)})},void 0),r=void 0,i=void 0}return n.promise=s,n.resolve=function(e){t||o(q(e))},n.fulfill=function(e){t||o(B(e))},n.reject=function(e){t||o(V(e))},n.notify=function(e){t||h(i,function(t,r){q.nextTick(function(){r(e)})},void 0)},n}function b(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=F();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function k(e){return b(function(t,r){for(var i=0,n=e.length;i<n;i++)q(e[i]).then(t,r)})}function w(e,t,r){void 0===t&&(t=function(e){return V(new Error("Promise does not support operation: "+e))}),void 0===r&&(r=function(){return{state:"unknown"}});var i=p(w.prototype);if(i.promiseDispatch=function(r,n,s){var o;try{o=e[n]?e[n].apply(i,s):t.call(i,n,s)}catch(e){o=V(e)}r&&r(o)},i.inspect=r,r){var n=r();"rejected"===n.state&&(i.exception=n.reason),i.valueOf=function(){var e=r();return"pending"===e.state||"rejected"===e.state?i:e.value}}return i}function O(e,t,r,i){return q(e).then(t,r,i)}function j(e){if(H(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function H(e){return e instanceof w}function x(e){return(t=e)===Object(t)&&"function"==typeof e.then;var t}"object"==typeof t&&t&&t.env&&t.env.Q_DEBUG&&(q.longStackSupport=!0),q.defer=F,F.prototype.makeNodeResolver=function(){var e=this;return function(t,r){t?e.reject(t):arguments.length>2?e.resolve(l(arguments,1)):e.resolve(r)}},q.Promise=b,q.promise=b,b.race=k,b.all=W,b.reject=V,b.resolve=q,q.passByCopy=function(e){return e},w.prototype.passByCopy=function(){return this},q.join=function(e,t){return q(e).join(t)},w.prototype.join=function(e){return q([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Q can't join: not the same: "+e+" "+t)})},q.race=k,w.prototype.race=function(){return this.then(q.race)},q.makePromise=w,w.prototype.toString=function(){return"[object Promise]"},w.prototype.then=function(e,t,r){var i=this,n=F(),s=!1;return q.nextTick(function(){i.promiseDispatch(function(t){s||(s=!0,n.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return V(e)}}(t)))},"when",[function(e){s||(s=!0,n.resolve(function(e){if("function"==typeof t){C(e,i);try{return t(e)}catch(e){return V(e)}}return V(e)}(e)))}])}),i.promiseDispatch(void 0,"when",[void 0,function(e){var t,i=!1;try{t=function(e){return"function"==typeof r?r(e):e}(e)}catch(e){if(i=!0,!q.onerror)throw e;q.onerror(e)}i||n.notify(t)}]),n.promise},q.tap=function(e,t){return q(e).tap(t)},w.prototype.tap=function(e){return e=q(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},q.when=O,w.prototype.thenResolve=function(e){return this.then(function(){return e})},q.thenResolve=function(e,t){return q(e).thenResolve(t)},w.prototype.thenReject=function(e){return this.then(function(){throw e})},q.thenReject=function(e,t){return q(e).thenReject(t)},q.nearer=j,q.isPromise=H,q.isPromiseAlike=x,q.isPending=function(e){return H(e)&&"pending"===e.inspect().state},w.prototype.isPending=function(){return"pending"===this.inspect().state},q.isFulfilled=function(e){return!H(e)||"fulfilled"===e.inspect().state},w.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},q.isRejected=function(e){return H(e)&&"rejected"===e.inspect().state},w.prototype.isRejected=function(){return"rejected"===this.inspect().state};var M,D,P,L=[],A=[],U=[],_=!0;function N(){L.length=0,A.length=0,_||(_=!0)}function V(e){var r=w({when:function(r){return r&&function(e){if(_){var r=m(A,e);-1!==r&&("object"==typeof t&&"function"==typeof t.emit&&q.nextTick.runAfter(function(){var i=m(U,e);-1!==i&&(t.emit("rejectionHandled",L[r],e),U.splice(i,1))}),A.splice(r,1),L.splice(r,1))}}(this),r?r(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,r){_&&("object"==typeof t&&"function"==typeof t.emit&&q.nextTick.runAfter(function(){-1!==m(A,e)&&(t.emit("unhandledRejection",r,e),U.push(e))}),A.push(e),r&&void 0!==r.stack?L.push(r.stack):L.push("(no stack) "+r))}(r,e),r}function B(e){return w({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},delete:function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return v(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function Q(e,t,r){return q(e).spread(t,r)}function Y(e,t,r){return q(e).dispatch(t,r)}function W(e){return O(e,function(e){var t=0,r=F();return h(e,function(i,n,s){var o;H(n)&&"fulfilled"===(o=n.inspect()).state?e[s]=o.value:(++t,O(n,function(i){e[s]=i,0==--t&&r.resolve(e)},r.reject,function(e){r.notify({index:s,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function X(e){if(0===e.length)return q.resolve();var t=q.defer(),r=0;return h(e,function(i,n,s){var o=e[s];r++,O(o,function(e){t.resolve(e)},function(e){if(0==--r){var i=e||new Error(""+e);i.message="Q can't get fulfillment value from any promise, all promises were rejected. Last error message: "+i.message,t.reject(i)}},function(e){t.notify({index:s,value:e})})},void 0),t.promise}function K(e){return O(e,function(e){return e=d(e,q),O(W(d(e,function(e){return O(e,s,s)})),function(){return e})})}q.resetUnhandledRejections=N,q.getUnhandledReasons=function(){return L.slice()},q.stopUnhandledRejectionTracking=function(){N(),_=!1},N(),q.reject=V,q.fulfill=B,q.master=function(e){return w({isDef:function(){}},function(t,r){return Y(e,t,r)},function(){return q(e).inspect()})},q.spread=Q,w.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},q.async=function(e){return function(){function t(e,t){var s;if("undefined"==typeof StopIteration){try{s=r[e](t)}catch(e){return V(e)}return s.done?q(s.value):O(s.value,i,n)}try{s=r[e](t)}catch(e){return function(e){return"[object StopIteration]"===g(e)||e instanceof u}(e)?q(e.value):V(e)}return O(s,i,n)}var r=e.apply(this,arguments),i=t.bind(t,"next"),n=t.bind(t,"throw");return i()}},q.spawn=function(e){q.done(q.async(e)())},q.return=function(e){throw new u(e)},q.promised=function(e){return function(){return Q([this,W(arguments)],function(t,r){return e.apply(t,r)})}},q.dispatch=Y,w.prototype.dispatch=function(e,t){var r=this,i=F();return q.nextTick(function(){r.promiseDispatch(i.resolve,e,t)}),i.promise},q.get=function(e,t){return q(e).dispatch("get",[t])},w.prototype.get=function(e){return this.dispatch("get",[e])},q.set=function(e,t,r){return q(e).dispatch("set",[t,r])},w.prototype.set=function(e,t){return this.dispatch("set",[e,t])},q.del=q.delete=function(e,t){return q(e).dispatch("delete",[t])},w.prototype.del=w.prototype.delete=function(e){return this.dispatch("delete",[e])},q.mapply=q.post=function(e,t,r){return q(e).dispatch("post",[t,r])},w.prototype.mapply=w.prototype.post=function(e,t){return this.dispatch("post",[e,t])},q.send=q.mcall=q.invoke=function(e,t){return q(e).dispatch("post",[t,l(arguments,2)])},w.prototype.send=w.prototype.mcall=w.prototype.invoke=function(e){return this.dispatch("post",[e,l(arguments,1)])},q.fapply=function(e,t){return q(e).dispatch("apply",[void 0,t])},w.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},q.try=q.fcall=function(e){return q(e).dispatch("apply",[void 0,l(arguments,1)])},w.prototype.fcall=function(){return this.dispatch("apply",[void 0,l(arguments)])},q.fbind=function(e){var t=q(e),r=l(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(l(arguments))])}},w.prototype.fbind=function(){var e=this,t=l(arguments);return function(){return e.dispatch("apply",[this,t.concat(l(arguments))])}},q.keys=function(e){return q(e).dispatch("keys",[])},w.prototype.keys=function(){return this.dispatch("keys",[])},q.all=W,w.prototype.all=function(){return W(this)},q.any=X,w.prototype.any=function(){return X(this)},q.allResolved=(M=K,D="allResolved",P="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(D+" is deprecated, use "+P+" instead.",new Error("").stack),M.apply(M,arguments)}),w.prototype.allResolved=function(){return K(this)},q.allSettled=function(e){return q(e).allSettled()},w.prototype.allSettled=function(){return this.then(function(e){return W(d(e,function(e){function t(){return e.inspect()}return(e=q(e)).then(t,t)}))})},q.fail=q.catch=function(e,t){return q(e).then(void 0,t)},w.prototype.fail=w.prototype.catch=function(e){return this.then(void 0,e)},q.progress=function(e,t){return q(e).then(void 0,void 0,t)},w.prototype.progress=function(e){return this.then(void 0,void 0,e)},q.fin=q.finally=function(e,t){return q(e).finally(t)},w.prototype.fin=w.prototype.finally=function(e){if(!e||"function"!=typeof e.apply)throw new Error("Q can't apply finally callback");return e=q(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},q.done=function(e,t,r,i){return q(e).done(t,r,i)},w.prototype.done=function(e,r,i){var n=function(e){q.nextTick(function(){if(C(e,s),!q.onerror)throw e;q.onerror(e)})},s=e||r||i?this.then(e,r,i):this;"object"==typeof t&&t&&t.domain&&(n=t.domain.bind(n)),s.then(void 0,n)},q.timeout=function(e,t,r){return q(e).timeout(t,r)},w.prototype.timeout=function(e,t){var r=F(),i=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),r.reject(t)},e);return this.then(function(e){clearTimeout(i),r.resolve(e)},function(e){clearTimeout(i),r.reject(e)},r.notify),r.promise},q.delay=function(e,t){return void 0===t&&(t=e,e=void 0),q(e).delay(t)},w.prototype.delay=function(e){return this.then(function(t){var r=F();return setTimeout(function(){r.resolve(t)},e),r.promise})},q.nfapply=function(e,t){return q(e).nfapply(t)},w.prototype.nfapply=function(e){var t=F(),r=l(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},q.nfcall=function(e){var t=l(arguments,1);return q(e).nfapply(t)},w.prototype.nfcall=function(){var e=l(arguments),t=F();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},q.nfbind=q.denodeify=function(e){if(void 0===e)throw new Error("Q can't wrap an undefined function");var t=l(arguments,1);return function(){var r=t.concat(l(arguments)),i=F();return r.push(i.makeNodeResolver()),q(e).fapply(r).fail(i.reject),i.promise}},w.prototype.nfbind=w.prototype.denodeify=function(){var e=l(arguments);return e.unshift(this),q.denodeify.apply(void 0,e)},q.nbind=function(e,t){var r=l(arguments,2);return function(){var i=r.concat(l(arguments)),n=F();return i.push(n.makeNodeResolver()),q(function(){return e.apply(t,arguments)}).fapply(i).fail(n.reject),n.promise}},w.prototype.nbind=function(){var e=l(arguments,0);return e.unshift(this),q.nbind.apply(void 0,e)},q.nmapply=q.npost=function(e,t,r){return q(e).npost(t,r)},w.prototype.nmapply=w.prototype.npost=function(e,t){var r=l(t||[]),i=F();return r.push(i.makeNodeResolver()),this.dispatch("post",[e,r]).fail(i.reject),i.promise},q.nsend=q.nmcall=q.ninvoke=function(e,t){var r=l(arguments,2),i=F();return r.push(i.makeNodeResolver()),q(e).dispatch("post",[t,r]).fail(i.reject),i.promise},w.prototype.nsend=w.prototype.nmcall=w.prototype.ninvoke=function(e){var t=l(arguments,1),r=F();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},q.nodeify=function(e,t){return q(e).nodeify(t)},w.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){q.nextTick(function(){e(null,t)})},function(t){q.nextTick(function(){e(t)})})},q.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var J=R();return q})}).call(this,r(3),r(6).setImmediate)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){var r,i,n=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var a,u=[],l=!1,h=-1;function m(){l&&a&&(l=!1,a.length?u=a.concat(u):h=-1,u.length&&d())}function d(){if(!l){var e=c(m);l=!0;for(var t=u.length;t;){for(a=u,u=[];++h<t;)a&&a[h].run();h=-1,t=u.length}a=null,l=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new p(e,t)),1!==u.length||l||c(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(e,t,r){"use strict";r.r(t);var i=r(0);function n(e,t){if(void 0===e)return t;const r={};for(const i in t)r[i]=void 0===e[i]?t[i]:e[i];return r}function s(e){for(const t in e)return!0;return!1}function o(e){if("object"!=typeof e)return null;for(const t in e)return t;return null}function c(e,t){for(const r of t)if(e==r)return!0;return!1}function a(e,t){if(void 0===e)return!1;for(const r of t){if(void 0===e[r])return!1;e=e[r]}return!0}function u(e,t,r){for(let i=0;i<t.length;i++){const n=t[i];void 0===e[n]&&(e[n]=r[i]),e=e[n]}return e}function l(e,t,r=!1){if(void 0!==e){for(const i of t)if(void 0===(e=e[i])&&!r)return;return e}}function h(e,...t){return function e(t,r,i){for(let s=0,o=r.length;s<o;++s){const o=r[s];if(!m(o)&&!f(o))continue;const c=Object.keys(o);for(let r=0,s=c.length;r<s;r++){const s=c[r],a=o[s];i&&m(a)?d(a)?t[s]=new Date(a.valueOf()):y(a)?t[s]=new RegExp(a):a.nodeName?t[s]=a.cloneNode(!0):(n=a)&&(n.nodeName||n.prop&&n.attr&&n.find)?t[s]=a.clone():(m(t[s])||(t[s]=p(a)?[]:{}),e(t[s],[a],!0)):t[s]=a}}var n;return t}(e,t,!1)}function m(e){return null!==e&&"object"==typeof e}function d(e){return"[object Date]"===toString.call(e)}const p=Array.isArray;function f(e){return"function"==typeof e}function y(e){return"[object RegExp]"===toString.call(e)}function v(e){return e&&e.window===e}function g(e){return void 0!==e}function S(e,t,r=5){const i=[],n=[];if("number"!=typeof r&&(r=5),t){if(e===t)throw new Error("Can't copy! Source and destination are identical.");if(p(t))t.length=0;else for(const e in t)delete t[e];return i.push(e),n.push(t),s(e,t,r)}return o(e,r);function s(e,t,r){if(--r<0)return"...";if(p(e))for(let i=0,n=e.length;i<n;i++)t.push(o(e[i],r));else if(null===(i=e)||"object"!=typeof i||Object.getPrototypeOf(i))if(e&&"function"==typeof e.hasOwnProperty)for(const i in e)e.hasOwnProperty(i)&&(t[i]=o(e[i],r));else for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=o(e[i],r));else for(const i in e)t[i]=o(e[i],r);var i;return t}function o(e,t=5){if(!m(e))return e;const r=i.indexOf(e);if(-1!==r)return n[r];if(v(e))throw new Error("Can't copy! Making copies of Window instances is not supported.");let c=!1,a=function(e){switch(toString.call(e)){case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return new e.constructor(o(e.buffer),e.byteOffset,e.length);case"[object ArrayBuffer]":if(!e.slice){const 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]":const t=new RegExp(e._source,e.toString().match(/[^/]*$/)[0]);return t.lastIndex=e.lastIndex,t;case"[object Blob]":return new e.constructor([e],{type:e.type})}if(f(e.cloneNode))return e.cloneNode(!0)}(e);return void 0===a&&(a=p(e)?[]:Object.create(Object.getPrototypeOf(e)),c=!0),i.push(e),n.push(a),c?s(e,a,t):a}}class C{constructor(){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"}formatResponse(e,t){for(const r of t)e[r.path]=this.formatResponseValue(r.apiColumn.type,e[r.path])}expandResponse(e,t,r){for(const i of r)e[i.path]=this.formatResponseValue(i.apiColumn.type,t[i.path])}formatRequest(e,t,r){const i={};for(const n of r){const r=n.id,s=n.apiColumn;s.readOnly||this.compareFields(s.type,e[r],t[r])||(i[r]=this.formatRequestValue(n.apiColumn.type,t[r]))}return i}hasChanges(e,t,r){for(const i of r){const r=i.id,n=i.apiColumn;if(!n.readOnly&&!this.compareFields(n.type,e[r],t[r]))return!0}return!1}getChanges(e,t,r){const i=[];for(const n of r){const r=n.id,s=n.apiColumn;s.readOnly||this.compareFields(s.type,e[r],t[r])||i.push({oldValue:e[r],newValue:t[r],column:n.apiColumn})}return i}copyFields(e,t,r){for(const i of r){const r=i.path;t[r]=this.clone(i.apiColumn.type,e[r])}return t}shallowCopyFields(e,t,r,i){for(const n of i){const i=n.path;r[i]=void 0!==e[i]?e[i]:this.clone(n.apiColumn.type,t[i])}return r}setDefaultValues(e,t){for(const r of t)e[r.id]=this.getDefaultValue(r.apiColumn.type);return e}compareFields(e,t,r){if(void 0===t)return void 0===r;if(void 0===r)return!1;switch(e){case"date":case"time":case"datetime":return this.compareMomentObjects(t,r);case"duration":return this.compareDurations(t,r);case"id":case"item":case"link":case"child":case"sibling":return t==r;case"current":case"dimension":case"distance":case"double":case"filesize":case"number":case"power":case"quantity":case"volume":case"weight":case"coordinate":case"price":case"percentage":return this.compareFloats(t,r);case"int":case"bool":case"enum":case"email":case"phone":case"url":case"text":case"longtext":case"color":return t===r;default:return function e(t,r){if(t===r)return!0;if(null===t||null===r)return!1;if(t!=t&&r!=r)return!0;const i=typeof t;let n,s,o;if(i===typeof r&&"object"===i){if(!p(t)){if(d(t))return!!d(r)&&((c=t.getTime())===(a=r.getTime())||c!=c&&a!=a);if(y(t))return!!y(r)&&t.toString()===r.toString();if(v(t)||v(r)||p(r)||d(r)||y(r))return!1;for(s in o=Object.create(null),t)if(!f(t[s])){if(!e(t[s],r[s]))return!1;o[s]=!0}for(s in r)if(!(s in o)&&g(r[s])&&!f(r[s]))return!1;return!0}if(!p(r))return!1;if(n=t.length,t.length===r.length){for(s=0;s<n;s++)if(!e(t[s],r[s]))return!1;return!0}}var c,a;return!1}(t,r)}}compareFloats(e,t){const r=Math.abs(e),i=Math.abs(t),n=Math.abs(e-t);return e===t||(0===e||0===t||n<Number.MIN_VALUE?n<1.19e-7*Number.MIN_VALUE:n/Math.min(r+i,Number.MAX_VALUE)<1.19e-7)}compareMomentObjects(e,t){return e.isValid()?!!t.isValid()&&e.isSame(t):!t.isValid()}compareDurations(e,t){return e.asMilliseconds()===t.asMilliseconds()}formatResponseValue(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?JSON.parse(t):t;case"number":return 0===t?null:t;case"filesize":return t/1e6;default:return t}}formatRequestValue(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}}formatResponseDate(e){return null===e?i.invalid():i(e)}formatResponseDuration(e){return i.duration(null===e?0:e,"seconds")}formatResponseColor(e){return"#"===e.charAt(0)?e:"#"+e}formatRequestDateTime(e){return e.isValid()?e.format(this.SERVER_DATETIME_FORMAT):null}formatRequestDate(e){return e.isValid()?e.format(this.SERVER_DATE_FORMAT):null}formatRequestDuration(e){return e.asSeconds()}formatRequestColor(e){return"#"===e.charAt(0)?e.substring(1):e}getDefaultValue(e){switch(e){case"int":case"double":case"percentage":case"price":return 0;case"item":case"link":case"child":case"sibling":return null;case"bool":return!1;case"enum":return"0";case"date":case"datetime":case"time":return i.invalid();case"duration":return i.duration();case"text":case"longtext":return"";case"color":return"#000000";default:return""}}isDefaultValue(e,t){return this.compareFields(e,t,this.getDefaultValue(e))}clone(e,t){switch(e){case"duration":return this.cloneDuration(t);case"date":case"datetime":return i(t);case"json":return S(t);default:return t}}getCloneFunction(e){switch(e){case"duration":return this.cloneDuration;case"date":case"datetime":return this.cloneDate;default:return this.identity}}cloneDuration(e){return i.duration(e)}cloneDate(e){return e.clone()}identity(e){return e}}class I{constructor(e,t){this.queryParserFactory=e,this.queryService=t}processOptions(e){return n(e,{columns:[],query:null,queryItemType:null,queryParams:{},parent:null,deferRequest:!1,limit:null,entryKey:"",addLocalItems:!1})}createQuery(e){const t=e.parent;let r;if(null===t)r=e.query;else{const i={linkedTo:t.itemType,query:{id:"&parentId"}};e.queryParams.parentId=t.itemId,r=null===e.query?i:this.queryService.addAndCondition(e.query,i)}const i=this.queryParserFactory.construct(r,e.queryParams).parse();return{object:i[0],string:i[1]}}getIdArray(e,t){void 0===t&&(t=[]);for(const r of e)t.push(r.itemId);return t}filterArray(e,t){const r=[],i=[];for(const n of e)t(n)?r.push(n):i.push(n);if(0===i.length)return i;e.length=r.length;for(let t=0;t<e.length;t++)e[t]=r[t];return i}}const E={CACHED:"cached",PROMISED:"promised",EXPAND:"expand",PROMISED_EXPAND:"promised-expand",RESOLVE:"resolve",LOCAL:"local"},R=">",q=":";class T{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m,d){this.errorHandler=e,this.itemRequestService=t,this.itemHandler=r,this.columnHandler=i,this.collectionEntryFactory=n,this.collectionCacheFactory=s,this.queryParserFactory=o,this.collectionEntryService=c,this.columnSetFactory=a,this.itemEntryService=u,this.keyService=l,this.promiseService=h,this.queryService=m,this.columnUtil=d,this.entries=this.collectionCacheFactory.construct()}getPromises(e){const t=e[E.PROMISED],r=e[E.PROMISED_EXPAND],i=[];for(const e in t)i.push(t[e]);for(const e in r)i.push(r[e]);return i}getRequestIds(e){const t=[];for(const r in e[E.RESOLVE])t.push(r);for(const r in e[E.EXPAND])t.push(r);return t}removeFromAndAddToCollections(e,t){for(const r in e){const i=e[r],n=i.collection;n.removeItems(i.notfitting,null,!0),n.addItems(i.fitting,null,!0),i.maybe.length>0&&n.extend(xe,null,!0,t)}}removeFromCollections(e,t,r=null){let i;for(const n in e){const s=e[n],o=s.fitting,c=s.maybe,a=s.collection,u=[];for(const e of o)u.push(e.itemId);for(const e of c)u.push(e);null!==r&&a===r.entry?i=a.removeItems(u,r,t):a.removeItems(u,null,t)}return i}addItemsToCollections(e){return this.addToCollections(this.createCollectionMap(e),!1)}addToCollections(e,t,r=null){let i;for(const n in e){const s=e[n],o=s.collection;o.isDeferred()||(null!==r&&o===r.entry?i=o.addItems(s.fitting,r,t):o.addItems(s.fitting,null,t),t&&s.maybe.length>0&&o.extend(xe,null,!0,t))}return i}batchExpand(e,t,r,i){if(0===i.length)return this.promiseService.when(r);const n=[];let s=[];for(const e in r)n.push(e),s=s.concat(r[e].entry.items);return this.itemRequestService.requestLinkItems(e,n,t,null,i).then(e=>{const o=this.itemRequestService.processExpansion(i,e,t,s);for(const e of n)r[e].entry.updateColumns(o)})}batchExtend(e,t,r,i,n,o=!1){if(!s(n))return{};const c=[];let a=[];r.queryParams=i(r.queryParams);for(const e in n){const t=n[e].entry;t.extendQuery(i),c.push(e),a=a.concat(t.getIdArray())}return this.itemRequestService.requestLinkItems(e,c,t,this.queryService.addAndCondition(this.collectionEntryService.createQuery(r).object,this.queryService.createNotIn(a)),r.columns).then(i=>this.itemRequestService.processLinkResponse(i,e,c,t,r),this.errorHandler.reject).then(e=>{const t={};for(const r of c){const i=n[r],s=i.entry.addItems(e.items[r],i);t[r]=o?i.items:s}return t},this.errorHandler.reject)}batchFetch(e,t,r,i,n){const o=this.createStatusResource(e,t,r,i,n);return this.promiseService.all(this.getPromises(o)).then(()=>{const t=this.getRequestIds(o);return t.length>0?this.itemRequestService.requestLinkItems(e,t,r,null===i.query?null:this.queryParserFactory.construct(i.query,i.queryParams).parse()[0],i.columns).then(n=>this.itemRequestService.processLinkResponse(n,e,t,r,i),this.errorHandler.reject).then(e=>this.handleBatchResponse(o,e),this.errorHandler.reject):s(o[E.LOCAL])?this.columnHandler.fetch(r,i.columns).then(e=>this.handleBatchResponse(o,{columns:this.columnSetFactory.construct(r,i.columns,e,!1)}),this.errorHandler.reject):o[E.CACHED]},this.errorHandler.reject)}clone(e,t,r={}){const i=e.itemType,n=e.items,s=[];void 0===r[i]&&(r[i]={});const o=r[i];for(const e of n)o[e.itemId]=this.keyService.getLocalId();for(const e of n){const i=this.itemHandler.cloneItem(o[e.itemId],e,r);null!==t.parent&&(i.parent=t.parent),s.push(i)}return this.create(i,t,e.columns,s)}create(e,t,r,i){return this.entries.add(this.collectionEntryFactory.construct(e,t)).resolve({columns:r,items:i})}createCollectionMap(e){const t={};for(const r of e)this.expandCollectionMap(r,t);return t}createStatusResource(e,t,r,i,n){const s={};for(const e in E)s[E[e]]={};for(const o of t){const t=this.collectionEntryService.processOptions(i);let c;t.parent={itemType:e,itemId:o},s[(c=this.getEntryStatus(r,t,n)).status][o]=c.entry}return s}expandCollectionMap(e,t,r=this.entries){const i=void 0!==e.parent?e.parent:{},n=r.getByFittingItem(i.itemType,i.itemId,e.itemType,this.itemEntryService.getFields(e));for(const r in n)for(const i of n[r]){const n=i.id;void 0===t[n]&&(t[n]={collection:i,fitting:[],notfitting:[],maybe:[]}),t[n][r].push("fitting"===r?e:e.itemId)}}fetch(e,t,r,i){const n=this.getEntryStatus(e,t,i),s=n.entry;switch(n.status){case E.CACHED:return this.promiseService.when(s);case E.PROMISED:return s.promise;case E.EXPAND:return s.expand(t.columns);case E.PROMISED_EXPAND:return s.promise.then(()=>s.expand(t.columns),this.errorHandler.reject);case E.RESOLVE:return this.resolveRemote(s,r);case E.LOCAL:return this.resolveLocal(s,r)}}getDeferredEntryStatus(e,t){const r=e.options,i=r.columns;let n=!1;return e.reloadQueued?(e.reloadQueued=!1,r.columns=this.columnUtil.mergeRequestColumns(t.columns,i).merged,{entry:e,status:e.isLocal()?E.LOCAL:E.RESOLVE}):(!0===i?(console.warn("Columns: true for collections is deprecated!"),n=!0):n=this.columnUtil.isColumnSubset(t.columns,i,!1),{entry:e,status:n?E.PROMISED:E.PROMISED_EXPAND})}getEntryStatus(e,t,r){const i=this.collectionEntryService.createQuery(t),n=this.entries.getByQuery(e,i);return null===n?this.getNewEntryStatus(e,i,t,r):n.isDeferred()?this.getDeferredEntryStatus(n,t):{entry:n,status:this.columnUtil.isColumnSubset(t.columns,n.columns.request,n.columns.true)?E.CACHED:E.EXPAND}}getNewEntryStatus(e,t,r,i){let n,s;if(r.deferRequest){if(null===(n=i.getByQuery(e,t)))return{entry:i.add(this.collectionEntryFactory.construct(e,r)),status:E.PROMISED};(s=n.options).columns=this.columnUtil.mergeRequestColumns(s.columns,r.columns).merged}else n=this.collectionEntryFactory.construct(e,r);return this.entries.add(n),{entry:n,status:n.isLocal()?E.LOCAL:E.RESOLVE}}handleBatchResponse(e,t){const r={};for(const t in e.cached)r[t]=e.cached[t];for(const i in e.resolve)r[i]=e.resolve[i].resolve({items:t.items[i],columns:t.columns});for(const i in e.expand){const n=e.expand[i];n.updateColumns(t.columnExpansion),r[i]=n}for(const i in e.local){const n=e.local[i];r[i]=n.resolve({items:this.itemHandler.entries.getByParent(n.parent.itemType,i,n.itemType),columns:t.columns})}return r}removeItemsFromAndAddItemsToCollections(e){return this.removeFromAndAddToCollections(this.createCollectionMap(e),!1)}removeItemsFromCollections(e){return this.removeFromCollections(this.createCollectionMap(e),!1)}resolveLocal(e,t){const r=e.itemType,i=e.options.columns;return this.columnHandler.fetch(r,i).then(n=>e.resolve({items:t.getByQuery(r,e.query),columns:this.columnSetFactory.construct(r,i,n,!1)}),this.errorHandler.reject)}resolveRemote(e,t){const r=e.itemType,i=e.options;let n;return this.itemRequestService.requestItems(e).then(t=>(n=this.columnSetFactory.construct(r,i.columns,t.fetchColumnsObject()),this.itemRequestService.processResponse(t,t.links[r],e.parent,n)),this.errorHandler.reject).then(s=>e.resolve({items:s.concat(i.addLocalItems?t.getLocalByQuery(r,e.query):[]),columns:n}),this.errorHandler.reject)}}class F{processOptions(e){return n(e,{editItems:!1,editCollection:!1,modInstant:!1,enableSave:!0,onItemsCreated:He,onChange:He,onAdd:He,onRemove:He,onAddInitial:He,onRemoveInitial:He,onDeactiveateItem:He,onDeactivateCollection:He,resourceKey:null,clearOnTabChange:!0,clearOnSubTabChange:!0,custom:null})}getIdArray(e){const t=[];for(const r of e)t.push(r.entry.itemId);return t}}class b{constructor(e){this.columnUtil=e,this.cache={},this.allColumns={}}setColumn(e,t){void 0===this.cache[e]&&(this.cache[e]={});const r=this.cache[e],i=t.id;return void 0===r[i]&&(r[i]=t),r[i]}setColumns(e,t,r){const i={};for(const e in r){const t=r[e];i[e]={};for(const r in t)i[e][r]=this.setColumn(e,t[r])}return!0===t&&(this.allColumns[e]=!0),i}retrieve(e,t){if(!0===t)return this.containsAll(e)?{cached:this.getColumns(e),missing:[]}:{cached:{},missing:!0};const r={},i=[];return this.retrieveColumns(e,t,i,r),{missing:i,cached:r}}containsAll(e){return!0===this.allColumns[e]}getColumns(e){const t=void 0===this.cache[e]?[]:this.cache[e],r={};return r[e]=t,r}retrieveColumns(e,t,r,i){this.retrieveColumn(e,"id",r,i);for(const n of t)this.retrieveColumn(e,n,r,i)}retrieveColumn(e,t,r,i){const n=this.columnUtil.parseRequestColumn(t),s=this.getColumn(e,n.id);if(void 0===s)return void r.push(t);if(void 0===i[e]&&(i[e]={}),i[e][n.id]=s,0===n.children.length)return;const o=[];if(this.retrieveColumns(s.itemType,n.children,o,i),0===o.length)return;const c={};c[n.id]=o,r.push(c)}getColumn(e,t){if(void 0!==this.cache[e])return this.cache[e][t]}}class k{constructor(e,t,r,i,n){this.apiRequestService=e,this.errorHandler=t,this.promiseService=r,this.cache=i,this.columnUtil=n}setColumn(e,t){return this.cache.setColumn(e,t)}setColumns(e,t,r){return this.cache.setColumns(e,t,r)}fetchItemTypeTranslations(e){const t=[],r={};for(const i of e){const e=t.push(this.fetch(i,["id"]));r[i]=e-1}return this.promiseService.all(t).then(e=>{const t={};for(let i=0;i<e.length;i++){const n=r[i];t[n]=e[n][n].id.name}return t},this.errorHandler.reject)}request(e,t,r={}){const i={[e]:t};return this.apiRequestService.columns(e,i,r).then(r=>this.cache.setColumns(e,t,r.fetchColumnsObject()),this.errorHandler.reject)}fetch(e,t,r={}){const i=this.cache.retrieve(e,t);return!0!==i.missing&&0===i.missing.length?this.promiseService.when(i.cached):this.request(e,i.missing,r).then(e=>this.columnUtil.mergeResponseColumns(e,i.cached).merged)}fetchAll(e){return this.cache.containsAll(e)?this.promiseService.when(this.cache.getColumns(e)):this.request(e,!0)}}class w{constructor(){}getColumnPath(e,t){let r="",i="";for(const t of e)i+=r+t.id,r=R;return null!==t&&(i+=q+t),i}getDateFormatOptions(e){const t=i(),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&&h(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}isFloatColumn(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}}isIntColumn(e){switch(e.type){case"int":case"number":case"quantity":return!0;default:return!1}}isNumberColumn(e){return this.isFloatColumn(e)||this.isIntColumn(e)}isCustomColumn(e){return"customfield"===e.fieldtype}isItemColumn(e,t=!0){switch(e.type){case"id":return t;case"item":case"child":case"sibling":case"link":return!0;default:return!1}}isDateColumn(e){switch(e.type){case"datetime":case"date":return!0;default:return!1}}isRenderedColumn(e){switch(e.type){case"datetime":case"date":case"duration":return!0;default:return!1}}isFilteredColumn(e){if("staffel"===e.id)return!0;if(void 0!==e.generator)return!0;switch(e.type){case"price":case"bool":case"enum":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}}isFormattedColumn(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}}isSelectableColumn(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}hasLocationProperty(e,t){return 0!=(t&e.location)}isEditableColumn(e){if(e.readOnly)return!1;switch(e.type){case"date":case"datetime":case"duration":return!1}return!0}isSearchableColumn(e){switch(e.type){case"email":case"phone":case"text":case"longtext":case"html":return!0;default:return!1}}getDefaultWeight(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}}getComparators(e){switch(e.type){case"dimension":case"weight":case"price":return["=",">","<"];case"date":case"datetime":case"time":case"duration":return[">","<"];default:return["=","!="]}}isColumnSubset(e,t,r){if(!0===e)return r;for(const r of e)if(!this.containsColumn(r,t))return!1;return!0}containsColumn(e,t){const r=this.parseRequestColumn(e),i=this.findColumn(r.id,t);if(-1===i)return!1;if(0===r.children.length)return!0;if("string"==typeof t[i])return!1;for(const e of r.children)if(!this.containsColumn(e,t[i][r.id]))return!1;return!0}responseColumnsAvailable(e,t,r){for(const i of t){const t=this.parseRequestColumn(i),n=t.children,s=r[e];let o;if(void 0===s)return!1;if(void 0===(o=s[t.id]))return!1;if(n.length>0&&!this.responseColumnsAvailable(o.itemType,n,r))return!1}return!0}mergeRequestColumns(e,t){if(!0===e)return{merged:!0,difference:[]};if(!0===t)return{merged:!0,difference:!0};const r=S(e),i=[];for(const e of t){const t=this.mergeRequestColumn(e,r);null!==t&&i.push(t)}return{merged:r,difference:i}}mergeRequestColumn(e,t){const r=this.parseRequestColumn(e),i=this.findColumn(r.id,t);if(-1===i)return t.push(e),e;if(0===r.children.length)return null;"string"==typeof t[i]&&(t[i]={[r.id]:[]});const n=[];for(const e of r.children){const s=this.mergeRequestColumn(e,t[i][r.id]);null!==s&&n.push(s)}return 0===n.length?null:{[r.id]:n}}parseRequestColumn(e){const t="string"==typeof e,r=t?e:o(e);return{id:r,children:t?[]:e[r]}}mergeResponseColumns(e,t){const r={},i={};for(const n in e){if(void 0===t[n]){r[n]=e[n];continue}const s=this.mergeResponseColumnMap(e[n],t[n]);r[n]=s.merged,i[n]=s.difference}for(const n in t)void 0===e[n]&&(r[n]=t[n],i[n]=t[n]);return{merged:r,difference:i}}mergeResponseColumnMap(e,t){const r={},i={};for(const t in e)r[t]=e[t];for(const n in t)g(e[n])||(r[n]=t[n],i[n]=t[n]);return{merged:r,difference:i}}isLocalColumnId(e){return"__"===e.substring(0,2)}processConfigColumns(e){const t=[];for(const r of e)this.isLocalColumnId(r)||this.processConfigColumn(this.parseConfigColumn(r),t);return t}processLocalConfigColumns(e,t,r,i){const n={};for(const e of t)n[e.id]=e;for(const t of e){const e=t.split(q),s=e[0];this.isLocalColumnId(s)?void 0!==n[s]&&(i(t,n[s]),delete n[s]):r(t,s,e[1])}}consolidateColumns(e,t,r){const i=[];let n=S(r);return this.processLocalConfigColumns(e,t,(e,t)=>{this.processConfigColumn(t.split(R),n)},(e,t)=>{i.push(t),n=this.mergeRequestColumns(n,t.valueOptions.requestColumns).merged}),{request:n,local:i}}parseConfigColumn(e){return e.split(q)[0].split(R)}processConfigColumn(e,t){const r=e[0];if(1===e.length)return void(-1===t.indexOf(r)&&t.push(r));let i=this.findColumnObject(r,t);-1===i&&(i=t.push({[r]:[]})-1),this.processConfigColumn(e.slice(1),t[i][r])}findColumnObject(e,t){for(let r=0;r<t.length;r++)if(o(t[r])===e)return r;return-1}findColumn(e,t){for(let r=0;r<t.length;r++){const i=t[r];if("string"!=typeof i){if(o(i)===e)return r}else if(i===e)return r}return-1}}class O{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m,d,p){this.apiRequestService=e,this.resourceCacheInterface=t,this.authInterface=r,this.errorHandler=i,this.itemHandler=n,this.collectionHandler=s,this.columnSetFactory=o,this.itemRequestService=c,this.resourceCacheFactory=a,this.moduleChangesCompilerFactory=u,this.collectionEntryService=l,this.collectionResourceService=h,this.itemEntryService=m,this.keyService=d,this.queryService=p}getItemDefinition(e,t,r){const i=this.keyService.parseStateKey(t),n={itemType:e,options:r,itemId:t};if(null!==i){switch(i.type){case"new":n.itemId=this.keyService.getLocalId();break;case"duplicate":r.duplicate=i.itemId,void 0===r.templateOptions&&(r.templateOptions={}),void 0===r.templateOptions.item&&(r.templateOptions.item=i.itemId),n.itemId=this.keyService.getLocalDuplicateId()}return n}return n.itemId=t,n}createCollectionMap(e,t){const r=this.getResourceCache(),i=r.collections,n={};for(const s of e)t&&r.addSingleItem(s,{},!1),this.collectionHandler.expandCollectionMap(s,n,i);return n}getItemById(e,t,r){return this.itemHandler.fetchItem(e,t,r).then(e=>this.addSingleItem(e,r,!1),this.errorHandler.reject)}getItemsById(e,t,r){return this.itemHandler.fetchItems(e,t,this.itemEntryService.processOptions(r)).then(e=>this.addSingleItems(e,r),this.errorHandler.reject)}getItemsByQuery(e,t,r){const i=this.itemEntryService.processOptions(r),n={};return n[e]=i.columns,this.apiRequestService.query(e,this.queryService.addParentCondition(t,i.parent),n).then(t=>this.itemRequestService.processResponse(t,t.links[e],i.parent,this.columnSetFactory.construct(e,i.columns,t.fetchColumnsObject())),this.errorHandler.reject).then(e=>this.addSingleItems(e,r),this.errorHandler.reject)}getDuplicateById(e,t,r){void 0===r&&(r={}),r.edit=!0;const i=this.getItemDefinition(e,this.keyService.getDuplicateStateKey(t),r);return this.getItemByDef(i,!1)}getNewResource(e,t,r,i){return void 0===t&&(t={}),t.edit=!0,void 0===i&&(i=!1),this.itemHandler.fetchItem(e,this.keyService.getLocalId(),this.itemEntryService.processOptions(t)).then(e=>{const n=this.addSingleItem(e.main,t,i),s=this.processLinkedItems(e.linked,t,!0);return r?{main:n,linked:s}:n},this.errorHandler.reject)}getCollectionDef(e,t){return{itemType:e,options:{entry:this.collectionEntryService.processOptions(t),resource:this.collectionResourceService.processOptions(t)}}}getLinkCollectionsDef(e,t,r,i,n){return{itemType:r,linkType:e,linkIdArray:t,linkField:i,options:{entry:this.collectionEntryService.processOptions(n),resource:this.collectionResourceService.processOptions(n)}}}getCollection(e,t,r){const i=this.getResourceCache(),n=this.collectionEntryService.processOptions(r);return n.query=t,this.collectionHandler.fetch(e,n,i.items,i.deferredCollections).then(e=>this.addCollection(e,r),this.errorHandler.reject)}_getCollection(e,t){const r=this.getResourceCache();return this.collectionHandler.fetch(e,this.collectionEntryService.processOptions(t),r.items,r.deferredCollections).then(e=>this.addCollection(e,t),this.errorHandler.reject)}getCollectionFromDef(e){const t=this.getResourceCache();return this.collectionHandler.fetch(e.itemType,e.options.entry,t.items,t.deferredCollections).then(t=>this.addCollection(t,e.options.resource,!1),this.errorHandler.reject)}getLinkCollection(e,t,r,i){const n=this.getResourceCache(),s=this.collectionEntryService.processOptions(i);return s.parent={itemType:e,itemId:t},this.collectionHandler.fetch(r,s,n.items,n.deferredCollections).then(e=>this.addCollection(e,i),this.errorHandler.reject)}getLinkCollections(e,t,r,i){return this.collectionHandler.batchFetch(e,t,r,this.collectionEntryService.processOptions(i),this.getResourceCache().deferredCollections).then(e=>this.addCollections(e,this.collectionEntryService.processOptions(i)),this.errorHandler.reject)}getLinkCollectionsFromDef(e){return this.collectionHandler.batchFetch(e.linkType,e.linkIdArray,e.itemType,e.options.entry,this.getResourceCache().deferredCollections).then(t=>this.addCollections(t,e.options.resource),this.errorHandler.reject)}getAllLinkCollections(e,t,r){return this.apiRequestService.query(e,{},{}).then(i=>this.getLinkCollections(e,i.links[e],t,r),this.errorHandler.reject)}getItemByDef(e,t){return this.itemHandler.fetchItem(e.itemType,e.itemId,this.itemEntryService.processOptions(e.options)).then(r=>{let i;return void 0!==r.linked?(this.processLinkedItems(r.linked,e.options,!1),i=r.main):i=r,this.addSingleItem(i,e.options,t)},this.errorHandler.reject)}cloneItem(e,t,r){return this.addSingleItem(this.itemHandler.cloneItem(e,t.entry),r)}cloneCollection(e,t,r){return this.addCollection(this.collectionHandler.clone(e.entry,this.collectionEntryService.processOptions(t),r),t)}saveCurrentTab(e,t,r,i,n){return this.saveCurrentResourceCache(e,t,r,i,n)}saveCurrentResourceCache(e,t,r=!1,i,n=!1){return this.getResourceCache().save(e,t,r,i).then(t=>e?t:this.resourceCacheInterface.updateTabParams(t,!n).then(()=>t,this.errorHandler.reject),this.errorHandler.reject)}getCurrentCollections(){return this.getResourceCache().collections}getCurrentItems(){return this.getResourceCache().items}getCurrentChanges(){const e=this.getResourceCache();if(void 0===e.rootItem)throw new Error("itemAdministrator: No root item!");return this.moduleChangesCompilerFactory.construct(e.rootItem,e.items,e.collections).process()}addSingleItem(e,t,r){return this.getResourceCache().addSingleItem(e,t,r)}addSingleItems(e,t){const r=this.getResourceCache(),i=[];for(const n of e)i.push(r.addSingleItem(n,t,!1));return i}addCollection(e,t,r){return void 0===r&&(r=!0),this.getResourceCache().addCollection(e,r?this.collectionEntryService.processOptions(t):t)}addCollections(e,t){const r=this.getResourceCache(),i={};for(const n in e)i[n]=r.addCollection(e[n],t);return i}processLinkedItems(e,t,r){const i=this.getResourceCache(),n=i.collections,s={};for(const o of e){const e=o.itemType,c=o.itemEntries,a={};s[e]=[];for(const o of c)s[e].push(i.addSingleItem(o,t,!1)),r&&this.collectionHandler.expandCollectionMap(o,a,n),"Projectnotitie"===e&&u(i.tabRequestParameters,[o.itemType,o.itemId],[{},{no_notification:!0}]);r&&this.collectionHandler.addToCollections(a,!1)}return s}getTabEntry(){return this.getResourceCache()}getResourceCache(){return this.resourceCacheInterface.getCacheManager(this.authInterface.getUserId())}resetTabEntry(){return this.resetResourceCache()}resetResourceCache(){const e=this.getResourceCache(),t=this.resourceCacheFactory.construct();e.clearResources(),this.resourceCacheInterface.setCacheManager(this.authInterface.getUserId(),t)}addToCollections(e,t){return this.collectionHandler.addToCollections(this.createCollectionMap(e,!0),!1,t)}removeFromCollections(e,t){return this.collectionHandler.removeFromCollections(this.createCollectionMap(e,!1),!1,t)}updateItemIdMap(e,t){if(void 0!==t)for(const r in t){const i=t[r];void 0!==e[r]&&(e[i]=e[r],delete e[r])}}createCollectionResource(e,t,r){return this.addCollection(e,t,r)}createItemResource(e,t,r){return this.addSingleItem(e,t,r)}createItemResources(e,t){return this.addSingleItems(e,t)}onBeforeSave(e,t){return this.getResourceCache().registerCallback("onBeforeSave",e,t)}onSaveSuccess(e,t){return this.getResourceCache().registerCallback("onSaveSuccess",e,t)}onSaveWithoutClosing(e,t){return this.getResourceCache().registerCallback("onSaveWithoutClosing",e,t)}}class j{constructor(e,t,r){this.apiFormatter=e,this.keyService=t,this.promiseService=r,this.undefinedItemError="Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken",this.ALL_PERMISSIONS=7}resetDerived(e,t){const r=e.columns.root,i=[];for(const e of r)-1!==t.indexOf(e.id)&&i.push(e);!function t(r){for(const i of r)i.isLeaf||t(i.children),delete e.derived[i.path]}(i)}defer(e,t){return e.deferred=this.promiseService.defer(),e.deferRequest=t,e}resolve(e){const t=e.deferred;return delete e.deferred,delete e.deferRequest,t.resolve(e),e}reject(e,t=this.undefinedItemError){return e.deferred.reject(t),delete e.deferred,delete e.deferRequest,e}clearResources(e){e.resources=[]}deactivateResources(e){const t=e.resources;for(const e of t)e.deactivate()}getFields(e){return void 0!==e.modified?e.modified:e.initial}expand(e,t,r,i){const n=i.difference;return e.columns=i.merged,this.apiFormatter.expandResponse(e.initial,t,n.main),this.apiFormatter.expandResponse(e.derived,r,n.derived),void 0===e.modified?e:(this.apiFormatter.expandResponse(e.modified,t,n.main),e)}processOptions(e){return n(e,{columns:!0,parent:null,templateOptions:{},templateColumns:{},deferRequest:!1})}getConversionValue(e,t,r){if(void 0!==r[e])return r[e][t]}updateFields(e,t,r=!0){const i=e.columns.main,n=e.columns.formatted.main,s=e.initial,o=e.modified;if(void 0!==o){for(const e of i){const i=e.id;(r||this.apiFormatter.compareFields(e.apiColumn.type,s[i],o[i]))&&(o[i]=t[i])}this.apiFormatter.formatResponse(o,n)}for(const e of i){const r=e.id;s[r]=t[r]}return this.apiFormatter.formatResponse(s,n),e}updateItemValue(e,t,r,i){const n=r.id,s=t[n];let o;"link"===r.type&&void 0===s?void 0!==e.parent&&(o=e.parent.itemId):o=this.getConversionValue(r.itemType,s,i),void 0!==o&&(t[n]=o)}updateItemFields(e,t){const r=e.columns.item,i=e.initial,n=e.modified;for(const s of r){const r=s.apiColumn;this.updateItemValue(e,i,r,t),void 0!==n&&this.updateItemValue(e,n,r,t)}}process(e){const t=e.columns.formatted;return this.apiFormatter.formatResponse(e.initial,t.main),this.apiFormatter.formatResponse(e.derived,t.derived),e}formatRequest(e){return void 0===e.modified?{}:this.apiFormatter.formatRequest(this.keyService.isLocalId(e.itemId)?{}:e.initial,e.modified,e.columns.main)}setDisplayName(e){if(void 0===e.modified)return;const t=this.getDisplayName(e);t&&(e.modified.displayname=t)}getDisplayName(e){const t=void 0===e.modified?e.initial:e.modified;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);case"Reparatie":return e.derived["materiaal>naam"];default:return t[this.getTitleField(e.itemType)]}}getFullName(e,t,r){return e.trim().concat(" ",t).trim().concat(" ",r)}getTitleField(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"}}getChanges(e,t){return void 0!==e.modified||t?this.apiFormatter.getChanges(e.initial,t?{}:e.modified,e.columns.main):[]}isLocal(e){return this.keyService.isLocalId(e.itemId)}isLockable(e){if(this.isLocal(e))return!1;switch(e.itemType){case"Project":case"Materiaal":case"Contact":case"Medewerker":case"Voertuig":case"Template":return!0;default:return!1}}hasChanges(e){return void 0!==e.modified&&this.apiFormatter.hasChanges(e.initial,e.modified,e.columns.main)}resetModified(e){const t=e.columns.main;if(void 0!==e.modified)for(const r of t)e.modified[r.id]=this.apiFormatter.clone(r.apiColumn.type,e.initial[r.id])}setInitial(e,t,r){let i;for(const r in t)e.initial[r]=t[r];if(void 0===e.modified)return r&&this.callOnChange(e,this.apiFormatter.copyFields(e.initial,{},e.columns.main)),e;i=this.apiFormatter.copyFields(e.modified,{},e.columns.main);for(const r in t)e.modified[r]=t[r];return r&&this.callOnChange(e,i),e}setModified(e,t){const r=e.columns,i=r.response[e.itemType];if(void 0===e.modified){const n=e.resources,s=e.initial,o=e.modified={};if(void 0===t)this.apiFormatter.copyFields(s,o,r.main);else{this.apiFormatter.shallowCopyFields(t,s,o,r.main);for(const e in t)void 0===i[e]&&(o[e]=t[e])}for(const e of n)e.fields=o;return e}if(void 0===t)return e;for(const r in t)e.modified[r]=t[r];return e}setDerived(e,t){for(const r in t)e.derived[r]=t[r];return e}processLocal(e,t,r,n,s){return e.initial={permissions:this.ALL_PERMISSIONS},this.updateFields(e,t),this.updateItemFields(e,s),this.setModified(e,r),e.modified.created=i(),e.derived=n,e}setParent(e,t,r){return e.parent={itemType:t,itemId:r},e}callOnChange(e,t){for(let r=0,i=e.resources.length;r<i;r++){const i=e.resources[r];null!==i&&i.options.onChange(i,t)}}}class H{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m,d){this.apiRequestService=e,this.authInterface=t,this.errorHandler=r,this.itemEntryFactory=i,this.columnHandler=n,this.itemCacheFactory=s,this.batchStatusFactory=o,this.columnExpansionFactory=c,this.columnSetFactory=a,this.itemEntryService=u,this.apiFormatter=l,this.keyService=h,this.promiseService=m,this.columnUtil=d,this.templates={},this.entries=this.itemCacheFactory.construct()}getItemId(e){return e.itemId}getPromise(e){return e.deferred.promise}fetchItem(e,t,r){const i=this.getEntryStatus(e,t,r),n=i.entry,s=i.status;return s===E.LOCAL?this.fetchTemplate(e,r.templateOptions,r.templateColumns).then(e=>this.resolveLocal(n,r.parent,e),e=>(this.itemEntryService.reject(n,e),e)):this.resolveCached(n,s,r)}fetchItems(e,t,r){const i=this.batchStatusFactory.construct(e=>this.getItemId(e),e=>this.getPromise(e)),n={};for(const n of t)i.add(this.getEntryStatus(e,n,r));return n.entries=i.getPromises(),i.hasRequests()&&(n.requests=this.requestItem(e,i.getRequestIds(),r.columns)),i.hasEntries([E.LOCAL])&&(n.template=this.fetchTemplate(e,r.templateOptions,r.templateColumns)),this.promiseService.all(n).then(t=>this.batchResolve(e,i,r.columns,t),this.errorHandler.reject)}resolveCached(e,t,r){const i=e.itemType,n=e.itemId,s=e.columns.request;switch(t){case E.CACHED:return this.promiseService.when(e);case E.PROMISED:return e.deferred.promise;case E.PROMISED_EXPAND:return e.deferred.promise.then(()=>this.resolveCached(e,this.getCachedEntryStatus(e,r),r),this.errorHandler.reject)}if(t===E.EXPAND){const t=this.columnUtil.mergeRequestColumns(s,r.columns).difference;this.requestItem(i,n,t).then(r=>{this.resolveExpansion(e,this.columnExpansionFactory.construct(i,t,r.fetchColumnsObject()),r)},t=>{this.itemEntryService.reject(e,t)})}else this.requestItem(i,n,s).then(t=>{this.resolveRemote(e,this.columnSetFactory.construct(i,s,t.fetchColumnsObject()),t)},t=>{this.itemEntryService.reject(e,t)});return e.deferred.promise}resolveLocal(e,t,r){const i=e.itemType,n=e.itemId,s=this.createConversionMap(i,n,!0,r.response);return e.columns=r.columns,null!==t&&this.itemEntryService.setParent(e,t.itemType,t.itemId),this.itemEntryService.processLocal(e,r.fields,{},{},s),this.setCreator(e),this.itemEntryService.resolve(e),{main:e,linked:this.createLocalEntries(i,n,r,s)}}resolveExpansion(e,t,r){const i=e.itemType,n=e.itemId,s=t(e.columns,!0);return null===s?e:(this.itemEntryService.expand(e,r.fetchObject(i,n),r.fetchDerivedObject(i,n,s.difference.root),s),this.itemEntryService.resolve(e))}resolveRemote(e,t,r){const i=e.itemType,n=e.itemId,s=r.fetchObject(i,n);return void 0===s?(this.itemEntryService.reject(e),this.entries.clear(e),null):this.resolveDeferredEntry(e,s,r.fetchDerivedObject(i,n,t.root),t)}fetchTemplate(e,t={},r={}){const i=s(t),n=o(r);if(!i){const t=this.templates[e];if(void 0!==t&&(null===n||this.columnUtil.responseColumnsAvailable(n,r[n],t.responseColumns)))return this.promiseService.when(t)}return this.promiseService.all([this.apiRequestService.template(e,t),null===n?{}:this.columnHandler.fetch(n,r[n])]).then(t=>{const r=t[0],n=this.columnUtil.mergeResponseColumns(r.fetchColumnsObject(),t[1]).merged,s={fields:r.fetchObject(e,r.links[e][0]),columns:this.columnSetFactory.construct(e,!0,n),response:r,responseColumns:n};return!i&&r.cacheable&&(this.templates[e]=s),s},this.errorHandler.reject)}getEntryStatus(e,t,r){const i=this.entries.get(e,t);return void 0===i?this.keyService.isLocalId(t)?{entry:this.createDeferredEntry(e,t,!0,!1),status:E.LOCAL}:{entry:this.createDeferredEntry(e,t,r.columns,r.deferRequest),status:r.deferRequest?E.PROMISED:E.RESOLVE}:{entry:i,status:this.getCachedEntryStatus(i,r)}}getCachedEntryStatus(e,t){const r=e.columns,i=this.itemEntryService.isLocal(e)||this.columnUtil.isColumnSubset(t.columns,r.request,r.true);return void 0!==e.deferred?e.deferRequest?(r.request=this.columnUtil.mergeRequestColumns(r.request,t.columns).merged,E.RESOLVE):i?E.PROMISED:E.PROMISED_EXPAND:i?E.CACHED:(this.itemEntryService.defer(e,!1),E.EXPAND)}createDeferredEntry(e,t,r,i){const n=this.createEntryStub(e,t);return n.columns={itemType:e,request:r,true:!0===r},this.itemEntryService.defer(n,i)}createEntryStub(e,t){return this.entries.add(this.itemEntryFactory.construct(e,t))}createEntry(e,t,r,i){return this.itemEntryService.process(this.entries.add(this.itemEntryFactory.construct(i.itemType,e,i,t,r)))}resolveDeferredEntry(e,t,r,i){return e.columns=i,e.initial=t,e.derived=r,this.itemEntryService.process(e),this.itemEntryService.resolve(e)}batchResolve(e,t,r,i){const n=i.requests,s=[E.EXPAND,E.PROMISED_EXPAND],o=[E.RESOLVE];let c=!0;if(t.hasEntries(s)){const i=this.columnExpansionFactory.construct(e,r,n.fetchColumnsObject());t.forEachEntry(s,e=>{this.resolveExpansion(e,i,n)})}if(t.hasEntries(o)){const i=this.columnSetFactory.construct(e,r,n.fetchColumnsObject());t.forEachEntry(o,e=>{null===this.resolveRemote(e,i,n)&&(c=!1)})}return t.forEachEntry([E.LOCAL],e=>{this.resolveLocal(e,null,i.template)}),c?t.getArray():this.errorHandler.reject({message:this.itemEntryService.undefinedItemError})}cloneItem(e,t,r){const i=t.columns,n=t.parent;void 0===r&&(r={[t.itemType]:{[t.itemId]:e}});const s=this.createEntry(e,this.apiFormatter.copyFields(this.itemEntryService.getFields(t),{},i.main),this.apiFormatter.copyFields(t.derived,{},i.derived),i);return this.itemEntryService.updateItemFields(s,r),s.modified=this.apiFormatter.copyFields(s.initial,{},i.main),n?this.itemEntryService.setParent(s,n.itemType,n.itemId):s}createConversionMap(e,t,r,i){const n=i.links[e][0],s={[e]:{[n]:t}};return r&&this.extendConversionMap(s,i.items[e][n].links,i),s}createLocalEntries(e,t,r,i){const n=this,s=r.response,o={},c={},a=[];for(const t in s.items)t!==e&&(o[t]=this.columnSetFactory.construct(t,!0,r.responseColumns));const u=(e,t,r)=>{const l={itemType:e,itemId:t},h=s.items[e][r].links;for(const e in h){const t=h[e];void 0===c[e]&&a.push({itemType:e,itemEntries:c[e]=[]});for(const r of t){const t=i[e][r],a=n.createEntryStub(e,t);a.columns=o[e],a.parent=l,this.itemEntryService.processLocal(a,s.fetchObject(e,r),{},{},i),this.setCreator(a),c[e].push(a),u(e,t,r)}}};return u(e,t,s.links[e][0]),a}createLocalEntry(e,t,r,i,n=null){const s=t.columns.itemType,o=this.createEntryStub(s,e);return o.columns=t.columns,null!==n&&(o.parent=n),this.itemEntryService.processLocal(o,t.fields,r,i,this.createConversionMap(s,e,!1,t.response)),this.setCreator(o),o}extendConversionMap(e,t,r){for(const i in t){const n=t[i];void 0===e[i]&&(e[i]={});for(const t of n)e[i][t]=this.keyService.getLocalId(),this.extendConversionMap(e,r.items[i][t].links,r)}}fetchTitle(e,t,r=!0){const i=this.itemEntryService.getTitleField(e);return this.fetchItem(e,t,this.itemEntryService.processOptions({columns:[i],deferRequest:r})).then(e=>void 0!==e.main?e.main.initial[i]:void 0!==e.modified?e.modified[i]:e.initial[i],this.errorHandler.reject)}requestItem(e,t,r){const i={[e]:r};return this.apiRequestService.query(e,{id:t},i)}updateItemId(e,t){const r=e.itemId;return e.itemId=t,this.entries.updateItemId(e,r)}setCreator(e){e.modified.creator=this.authInterface.getUserId(),e.derived["creator>displayname"]=this.authInterface.getUserDisplayname()}}class x{constructor(e,t,r,i,n,s,o,c,a){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.columnHandler=i,this.columnExpansionFactory=n,this.columnSetFactory=s,this.itemEntryService=o,this.queryService=c,this.promiseService=a}requestItem(e,t,r){const i={[e]:r};return this.apiRequestService.query(e,{id:t},i)}requestItems(e,t=e.query.object,r=e.options.columns){const i=e.options,n={requestType:"query",columns:{[e.itemType]:r},query:t,itemType:"",allLinkIds:!1,limit:null};return null===i.queryItemType?n.itemType=e.itemType:(n.itemType=i.queryItemType,n.allLinkIds=!0),null!==i.limit&&(n.limit=i.limit),this.apiRequestService.requestSkeleton(n)}requestLinkItems(e,t,r,i,n){const s={[r]:n};return null===i?this.apiRequestService.query(e,{id:t},s):this.apiRequestService.query(r,this.queryService.addAndCondition(i,{linkedTo:e,query:{id:t}}),s)}processExpansion(e,t,r,i){const n=this.columnExpansionFactory.construct(r,e,t.fetchColumnsObject());for(const e of i)this.itemEntryService.isLocal(e)||this.handleCachedItem(e,t,n);return n}processResponse(e,t,r,i,n){void 0===n&&(n=this.columnExpansionFactory.construct(i.itemType,!!i.true||i.request,i.response));const s=i.itemType,o=i.root,c=[],a=[];for(const u of t){let t=this.itemHandler.entries.get(s,u);void 0===t?(t=this.itemHandler.createEntry(u,e.fetchObject(s,u),e.fetchDerivedObject(s,u,o),i),c.push(t)):void 0!==t.deferred?t.deferRequest?c.push(this.itemHandler.resolveDeferredEntry(t,e.fetchObject(s,u),e.fetchDerivedObject(s,u,o),i)):a.push(t.deferred.promise):c.push(this.handleCachedItem(t,e,n)),null!==r&&(t.parent=r)}return this.promiseService.all(a).then(t=>{for(const r of t)c.push(this.handleCachedItem(r,e,n));return c},this.errorHandler.reject)}handleCachedItem(e,t,r){const i=r.run(e.columns,!0);return null===i?e:this.itemEntryService.expand(e,t.fetchObject(e.itemType,e.itemId),t.fetchDerivedObject(e.itemType,e.itemId,i.difference.root),i)}processLinkResponse(e,t,r,i,n){const s=e.fetchColumnsObject(),o=this.columnSetFactory.construct(i,n.columns,s),c=this.columnExpansionFactory.construct(i,n.columns,s),u=e.items[t],l={};for(const n of r)l[n]=a(u,[n,"links",i])?this.processResponse(e,u[n].links[i],{itemType:t,itemId:n},o,c.run):[];return this.promiseService.all(l).then(e=>({items:e,columns:o,columnExpansion:c.run}),this.errorHandler.reject)}}class M{constructor(e){this.itemEntryService=e}processOptions(e){return n(e,{edit:!1,onChange:He,onDeactivate:He})}compareOptions(e,t){for(const r in e)if(e[r]!==t[r])return!1;return!0}isNew(e){return this.itemEntryService.isLocal(e.entry)&&void 0===e.transactions}}class D{constructor(){this.NEW_PREFIX="-1",this.DUPLICATE_PREFIX="-2",this.NEW_KEYWORD="new-",this.DUPLICATE_KEYWORD="dup-",this.seperator=":"}getSingleKey(e,t){return e.concat(this.seperator,String(t))}getCollectionCacheKey(e,t,r){return e.concat(this.seperator,String(t),this.seperator,r)}getCssKey(){return Array.prototype.join.call(arguments,"_")}parseStateKey(e){return 0===(e=e.toString()).indexOf(this.NEW_KEYWORD)?{type:"new",template:e.substring(this.NEW_KEYWORD.length)}:0===e.indexOf(this.DUPLICATE_KEYWORD)?{type:"duplicate",itemId:e.substring(this.DUPLICATE_KEYWORD.length)}:null}getDuplicateStateKey(e){return this.DUPLICATE_KEYWORD.concat(String(e))}getNewStateKey(e){return this.NEW_KEYWORD.concat(e)}getLocalId(){return parseInt(this.NEW_PREFIX.concat(this.getRandomString()),10)}getLocalDuplicateId(){return parseInt(this.DUPLICATE_PREFIX.concat(this.getRandomString()),10)}getRandomString(){return Math.random().toString().split(".")[1].substr(0,8)}isLocalId(e){return void 0!==e&&this.isNewId(e)||this.isDuplicateId(e)}isNewId(e){return 0===e.toString().indexOf(this.NEW_PREFIX)||e===this.NEW_KEYWORD}isDuplicateId(e){return 0===e.toString().indexOf(this.DUPLICATE_PREFIX)||e===this.DUPLICATE_KEYWORD}}class P{constructor(e,t,r,i){this.apiRequestService=e,this.errorHandler=t,this.keyService=r,this.promiseService=i,this.lockItems={},this.promises={}}getValue(e,t){const r=e.itemType;if(void 0!==t[r])return t[r][e.itemId]}setValue(e,t,r){return u(r,[e.itemType,e.itemId],[{},t])}getLocks(){return this.lockItems}hasLock(e){for(const t in this.lockItems)for(const r in this.lockItems[t]){const i=this.lockItems[t][r];if(!i.isForeign&&i.id==e)return!0}return!1}isLocked(e){const t=this.getValue(e,this.lockItems);return void 0!==t&&t.isForeign}getMessage(e){const t=this.getValue(e,this.lockItems);if(void 0!==t&&t.isForeign)return t.message}fetchCachedLock(e){const t=this.getValue(e,this.lockItems);if(void 0!==t)return this.promiseService.when(t);const r=this.getValue(e,this.promises);return void 0!==r?r:this.promiseService.when()}fetchLock(e){return this.fetchCachedLock(e).then(t=>void 0!==t?t:this.requestLock(e),this.errorHandler.reject).then(e=>e.isForeign?this.errorHandler.reject(e.message):e.token,this.errorHandler.reject)}requestLock(e){const t=e.itemType,r=e.itemId,i=this.apiRequestService.create("Locktoken",this.keyService.getLocalId(),{itemtype:t,item:r}).then(i=>(delete this.promises[t][r],this.setValue(e,i.fetchObject("Locktoken",i.links.Locktoken[0]),this.lockItems)),i=>(delete this.promises[t][r],301===i.code?this.setValue(e,{isForeign:!0,message:i.message},this.lockItems):this.errorHandler.reject(i)));return this.setValue(e,i,this.promises)}deleteLock(e){return this.fetchCachedLock(e).then(t=>{if(void 0!==t){if(!t.isForeign)return this.apiRequestService.delete("Locktoken",t.id).then(()=>{this.clearLock(e)},this.errorHandler.reject);this.clearLock(e)}},this.errorHandler.reject)}clearLock(e){const t=e.itemType;return void 0!==this.lockItems[t]&&delete this.lockItems[t][e.itemId]}}var L,A=r(1);class U{all(e){return Object(A.all)(e)}when(e){return Object(A.when)(e)}reject(e){return Object(A.reject)(e)}defer(){return Object(A.defer)()}}class _{constructor(){}addAndCondition(e,t){return void 0===e.conditions||"or"===e.operator?{conditions:[e,t]}:{conditions:e.conditions.concat(t)}}addOrCondition(e,t){return"or"===e.operator?{conditions:e.conditions.concat(t)}:{conditions:[e,t],operator:"or"}}addParentCondition(e,t){let r;return null===t?e:(r={linkedTo:t.itemType,query:t.itemId},null===e?r:this.addAndCondition(e,r))}createNotIn(e){return{comparator:"NOT IN",key:"id",value:e}}}class N{constructor(e,t,r){this.promiseService=e,this.getItemId=t,this.getPromise=r,this.entries={};for(const e in E)this.entries[E[e]]=[]}add(e){const t=e.status;void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e.entry)}hasEntries(e){for(const t of e)if(this.entries[t].length>0)return!0;return!1}hasRequests(){return this.hasEntries([E.RESOLVE,E.EXPAND,E.PROMISED_EXPAND])}forEachEntry(e,t){for(const r of e){const e=this.entries[r];for(const r of e)t(r)}}getPromises(){const e=[];return this.forEachEntry([E.PROMISED,E.PROMISED_EXPAND],t=>{e.push(this.getPromise(t))}),this.promiseService.all(e)}getRequestIds(){const e=[];return this.forEachEntry([E.RESOLVE,E.EXPAND,E.PROMISED_EXPAND],t=>{e.push(this.getItemId(t))}),e}getArray(){const e=[];for(const t in this.entries){const r=this.entries[t];for(const t of r)e.push(t)}return e}}class V{constructor(e){this.promiseService=e}construct(e,t){return new N(this.promiseService,e,t)}}class B{constructor(e,t,r,i){this.itemEntryService=e,this.singleItems=t,this.collections=r,this.collectionOptions=i,this.compilation={create:{},delete:{},update:{},move:{}},this.moveArray=[],this.deleteMap={},this.processSingleItems(),this.processCollections(),this.postProcess()}getParent(e){return void 0!==e.parent?e.parent:{itemType:"Void",itemId:0}}addMoveEntry(e){this.moveArray.push(e)}addDeleteEntry(e,t,r){u(this.deleteMap,[e.itemType,e.itemId],[{},{parentId:t,item:e,parentType:r}])}addUpdateEntry(e){u(this.compilation.update,[e.itemType,e.itemId],[{},e])}addCreateEntry(e){const t=this.getParent(e);u(this.compilation.create,[t.itemType,t.itemId,e.itemType,e.itemId],[{},{},{},e])}postProcess(){for(const e of this.moveArray){const t=e.itemId,r=this.deleteMap[e.itemType];if(void 0===r||void 0===r[t])continue;const i=e.parent;u(this.compilation.move,[i.itemType,i.itemId],[{},[]]).push(r[t]),delete r[t]}for(const e in this.deleteMap)for(const t in this.deleteMap[e]){const r=this.deleteMap[e][t].item,i=this.compilation.delete;void 0===i[e]&&(i[e]=[]),i[e].push(r)}}processSingleItems(){for(const e of this.singleItems)this.itemEntryService.isLocal(e)?this.addCreateEntry(e):this.itemEntryService.hasChanges(e)&&this.addUpdateEntry(e)}isEditableCollection(e){return void 0===this.collectionOptions||this.collectionOptions[e.id].edit}hasEditableItems(e){return void 0===this.collectionOptions||this.collectionOptions[e.id].editItems}processCollections(){for(const e of this.collections){if(e.isDeferred())continue;const t=e.parent,r=null!==t?t.itemId:0;if(this.isEditableCollection(e)){let i,n;e.isLocal()?(i=e.items,n=[]):(i=e.getAddedItems(),n=e.getRemovedItems());for(const e of i)this.itemEntryService.isLocal(e)?this.addCreateEntry(e):this.addMoveEntry(e);for(const e of n)this.addDeleteEntry(e,r,t.itemType)}if(this.hasEditableItems(e)){const t=e.getUpdatedItems();for(const e of t)this.addUpdateEntry(e)}}}}class Q{constructor(e){this.itemEntryService=e}construct(e,t,r){return new B(this.itemEntryService,e,t,r)}}class Y{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m){this.apiRequestService=e,this.itemHandler=t,this.errorHandler=r,this.collectionHandler=i,this.columnHandler=n,this.changesCompilerFactory=s,this.createRequestFactory=o,this.columnExpansionFactory=c,this.requestColumnExpansionFactory=a,this.collectionEntryService=u,this.itemEntryService=l,this.apiFormatter=h,this.promiseService=m}getItemTypeUpdatePriority(e){switch(e){case"Factuurregelbedrag":return 0;case"Factuurregel":case"Minfactuur":return 1;default:return 2}}buildMoveRequest(e){const t={};for(const r of e){const e=r.item,i=e.itemType;void 0===t[i]&&(t[i]=[]),t[i].push(e.itemId)}return t}getMapValue(e,t,r){if(void 0!==r&&void 0!==r[e])return r[e][t]}execute(e,t,r=!1,i,n,s){return this.executeRequests(this.changesCompilerFactory.construct(e,t,n),i,r,s)}executeCreateRequests(e,t,r,i,n){const s=this.createRequestFactory.construct(e,t,i).run(),o=[];for(const e of s)o.push(this.executeCreateRequest(e,r).then(c));return this.promiseService.all(o).then(()=>r,this.errorHandler.reject);function c(e){return f(n)&&n(r),e}}executeCreateRequest(e,t){return this.apiRequestService.requestSkeleton(e.request).then(r=>{const i=r.map,n=r.fetchColumnsObject(),s=e.items;for(const t in s){const o=this.columnExpansionFactory.construct(t,e.request.columns[t],n).run;for(const e in s[t]){const n=s[t][e],c=this.getMapValue(t,e,i);if(void 0===c){console.warn("Create failed!",n);continue}this.itemHandler.updateItemId(n,c);const a=r.fetchObject(t,c),u=o(n.columns,!0);this.itemEntryService.updateFields(n,a),null!==u&&this.itemEntryService.expand(n,a,r.fetchDerivedObject(t,c,u.difference.root),u)}}this.collectionHandler.addToCollections(e.collections,!0);for(const e in i){void 0===t[e]&&(t[e]={});for(const r in i[e])t[e][r]=i[e][r]}},this.errorHandler.reject)}prioritizeUpdateRequests(e,t){const r=[[],[],[]];let i=this.promiseService.when();for(const t in e)r[this.getItemTypeUpdatePriority(t)].push(t);for(const n of r)0!==n.length&&(i=i.then(this.executeUpdateRequests(n,e,t),this.errorHandler.reject));return i}executeUpdateRequests(e,t,r){return()=>{const i=[];for(const n of e)i.push(this.executeUpdateRequest(n,t[n],r));return this.promiseService.all(i)}}executeUpdateRequest(e,t,r){const i={},n=this.requestColumnExpansionFactory.construct(),s={};i[e]={};for(const o in t){const c=t[o],a=i[e][o]={},u=l(r,[e,o]);a.values=this.itemEntryService.formatRequest(c),void 0!==u&&(a.parameters=u),n.expand(c.columns),this.collectionHandler.expandCollectionMap(c,s)}for(const e in s){const t=s[e];t.fitting.length>0&&n.expand(t.collection.columns)}return this.apiRequestService.updateItems(e,i,n.get()).then(r=>{const i=this.columnExpansionFactory.construct(e,n.get(),r.fetchColumnsObject());for(const n in t){const s=t[n],o=r.fetchObject(e,n);if(void 0===o){console.warn("Update failed!",s);continue}const c=this.apiFormatter.copyFields(s.initial,{},s.columns.main);this.itemEntryService.setDerived(s,r.fetchDerivedObject(e,n,s.columns.root)),this.itemEntryService.updateFields(s,o),this.itemEntryService.callOnChange(s,c);const a=i.run(s.columns,!0);null!==a&&this.itemEntryService.expand(s,o,r.fetchDerivedObject(e,n,a.difference.root),a)}this.collectionHandler.removeFromAndAddToCollections(s)},this.errorHandler.reject)}executeDeleteRequests(e){const t=[];for(const r in e)t.push(this.executeDeleteRequest(r,e[r]));return this.promiseService.all(t)}executeDeleteRequest(e,t){const r=[];for(const e of t)r.push(e.itemId);return this.apiRequestService.delete(e,r).then(e=>{const r=e.items,i={};for(const e of t)c(e.itemId,r)||console.warn("Delete failed!",e),this.collectionHandler.expandCollectionMap(e,i);this.collectionHandler.removeFromCollections(i,!0)},this.errorHandler.reject)}executeMoveRequests(e,t){const r=this,i=[];for(const t in e)for(const r in e[t])n(t,r);return this.promiseService.all(i);function n(n,s){const o=e[n][s],c=this.getMapValue(n,s,t);i.push(r.apiRequestService.moveItems(n,void 0!==c?c:s,this.buildMoveRequest(o)).then(e=>{r.processMoveResponse(e,o)},r.errorHandler.reject))}}processMoveResponse(e,t){const r=[],i={},n={};for(const e of t){const t=e.item;this.addCollectionMapEntry(i,e.parentId,t,t.itemId),this.addCollectionMapEntry(n,t.parent.itemId,t,t),r.push(t)}this.forEachCollection(i,"removeItems"),this.forEachCollection(n,"addItems")}addCollectionMapEntry(e,t,r,i){u(e,[r.parent.itemType,t,r.itemType],[{},{},[]]).push(i)}forEachCollection(e,t){for(const r in e)for(const i in e[r])for(const n in e[r][i])this.collectionHandler.entries.getByParent(r,i,n)[t](e[r][i][n],null,!0)}onItemsCreated(e,t,r){if(s(e)){for(const t of r){const r=t.parent,i=t.getUpdatedItemColumns(e);if(null!==r){const i=this.getMapValue(r.itemType,r.itemId,e);void 0!==i&&(r.itemId=i),t.query=this.collectionEntryService.createQuery(t.options)}s(i)&&(void 0!==i.id&&t.onItemsCreated(e[t.itemType]),t.forEach(t=>{this.itemEntryService.updateItemFields(t,e)}))}for(const r of t){const t=r.parent;if(this.itemEntryService.updateItemFields(r,e),void 0!==t){const r=this.getMapValue(t.itemType,t.itemId,e);void 0!==r&&(t.itemId=r)}}}}executeRequests(e,t,r,i){const n=e.compilation,s=e.singleItems,o=e.collections,c={};return this.executeCreateRequests(n.create,t,c,r,i).then(()=>(this.onItemsCreated(c,s,o),this.executeMoveRequests(n.move,c)),e=>(this.onItemsCreated(c,s,o),this.errorHandler.reject(e))).then(()=>this.executeDeleteRequests(n.delete),this.errorHandler.reject).then(()=>this.prioritizeUpdateRequests(n.update,t),this.errorHandler.reject).then(()=>c,this.errorHandler.reject)}}class W{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=i,this.columnHandler=n,this.changesCompilerFactory=s,this.createRequestFactory=o,this.columnExpansionFactory=c,this.requestColumnExpansionFactory=a,this.collectionEntryService=u,this.itemEntryService=l,this.apiFormatter=h,this.promiseService=m}construct(){return new Y(this.apiRequestService,this.itemHandler,this.errorHandler,this.collectionHandler,this.columnHandler,this.changesCompilerFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,this.apiFormatter,this.promiseService)}}(L||(L={})).MAYBE="maybe";class X{constructor(e){this.queryMatcherFactory=e,this.entries={}}contains(e){for(const t in this.entries)for(const r of this.entries[t])if(e===r)return!0;return!1}some(e){for(const t in this.entries)for(const r of this.entries[t])if(e(r))return!0;return!1}forEach(e){for(const t in this.entries)for(const r of this.entries[t])e(r)}toArray(){const e=[];for(const t in this.entries)for(const r of this.entries[t])e.push(r);return e}add(e){const t=e.itemType;return void 0===this.entries[t]&&(this.entries[t]=[]),this.entries[t].push(e),e}clear(e){if(void 0===e)return this.entries={},!0;const t=e.itemType;if(void 0===this.entries[t])return!1;const r=this.entries[t].indexOf(e);return-1!==r&&(this.entries[t].splice(r,1),!0)}getByItemType(e){return void 0===this.entries[e]?[]:this.entries[e].slice()}getByParent(e,t,r){if(void 0===this.entries[r])return null;for(const i of this.entries[r])if(i.matchParent(e,t))return i;return null}getResourceByParent(e,t,r){const i=this.getByParent(e,t,r);return null===i?null:i.getCurrentResource()}getCollectionsByParent(e,t){const r=[];for(const i in this.entries)for(const n of this.entries[i])n.matchParent(e,t)&&r.push(n);return r}getByContainingItem(e,t){const r=[];if(void 0===this.entries[e])return r;for(const i of this.entries[e])void 0!==i.getItemById(t)&&r.push(i);return r}getByFittingItem(e,t,r,i){const n=[],s=[],o=[],c={fitting:n,notfitting:o,maybe:s};if(void 0===this.entries[r])return c;const a=this.queryMatcherFactory.construct(e,t,i,r);for(const e of this.entries[r]){const t=a.matchQuery(e.query.object);!0===t?n.push(e):t===L.MAYBE?s.push(e):o.push(e)}return c}getByQuery(e,t){if(void 0===this.entries[e])return null;for(const r of this.entries[e])if(r.query.string===t.string)return r;return null}getByKey(e,t){const r=[];if(void 0===this.entries[e])return r;for(const i of this.entries[e])i.options.entryKey===t&&r.push(i);return r}getResourceByKey(e,t){const r=[];if(void 0===this.entries[e])return r;for(const i of this.entries[e])for(const e of i.resources)null!==e&&e.options.resourceKey===t&&r.push(e);return r}}class K{constructor(e){this.queryMatcherFactory=e}construct(){return new X(this.queryMatcherFactory)}}let J=0;class z{constructor(e,t,r,i,n,s,o,c,a){this.errorHandler=e,this.collectionEntryService=t,this.itemRequestService=r,this.itemEntryService=i,this.keyService=n,this.queryService=s,this.promiseService=o,this.itemType=c,this.options=a,this.id=J++,this.parent=null,this.initial=[],this.items=[],this.resources=[],this.deferred=this.promiseService.defer(),this.itemType=c,this.options=a,this.query=t.createQuery(a)}isDeferred(){return void 0!==this.promise}resolve(e){const t=this.deferred;return this.columns=e.columns,this.initial=e.items,this.items=e.items.slice(),delete this.deferred,delete this.promise,t.resolve(this),this}isLocal(){const e=this.parent;return null!==e&&this.keyService.isLocalId(e.itemId)}matchParent(e,t){const r=this.parent;return null!==r&&r.itemType===e&&r.itemId==t}forEach(e){const t=this.items;for(const r of t)e(r)}getItemById(e){const t=this.items;for(const r of t)if(r.itemId===e)return r}getIdArray(e={}){return this.collectionEntryService.getIdArray(this.items,e)}addItems(e,t,r=!1,i=!0){if(0===e.length)return[];const n=this.resources,s=this.parent,o=this.columns.link;if(r){const t=this.initial,r=[];for(const i of e)-1===t.indexOf(i)&&(t.push(i),r.push(i));if(r.length>0)for(const e of n)e.options.onAddInitial(r,this)}const c=this.items,a=[];for(const t of e)-1===c.indexOf(t)&&(null!==s&&(t.parent=s,null!==o&&void 0!==t.modified&&(t.modified[o.id]=s.itemId)),c.push(t),a.push(t));if(a.length>0){let e;for(const r of n){const n=r.addItemResources(a);r===t?(e=n,i&&r.callOnAdd(n)):r.callOnAdd(n)}return e}return null===t?null:[]}removeItems(e,t,r,i){return 0===e.length?[]:this.handleRemovedItems(t=>c(t.itemId,e),t,r,i)}clear(e,t,r){return this.handleRemovedItems(()=>!1,e,t,r)}handleRemovedItems(e,t,r,i){void 0===i&&(i=!0);const n=this.resources,s=this.collectionEntryService.filterArray(this.items,e),o=r?this.collectionEntryService.filterArray(this.initial,e):[];if(o.length>0)for(const e of n)e.options.onRemoveInitial(o,this);if(0===s.length)return null===t?null:[];let c;for(const e of s)this.itemEntryService.deactivateResources(e);for(const e of n){const r=e.removeItemResources(s);e===t?(c=r,i&&e.callOnRemove(r)):e.callOnRemove(r)}return c}expand(e){const t=this.itemType;return 0===e.length?this.promiseService.when(this):(this.promise=this.itemRequestService.requestItems(this,void 0,e).then(r=>{const i=r.items[t],n=this.itemRequestService.processExpansion(e,r,t,this.items);return this.handleRemovedItems.call(this,e=>void 0!==i[e.itemId]||this.itemEntryService.isLocal(e),null,!0,!0),this.updateColumns(n),delete this.promise,this},this.errorHandler.reject),this.promise)}extendQuery(e){const t=this.options;return void 0===e?this.query:(t.queryParams=e(t.queryParams),this.query=this.collectionEntryService.createQuery(t))}extend(e,t,r,i){const n=this.extendQuery(e).object,s=this.queryService.addAndCondition(n,this.queryService.createNotIn(this.getIdArray())),o=this.itemRequestService.requestItems(this,null!==this.options.limit?n:s).then(e=>this.itemRequestService.processResponse(e,e.links[this.itemType],this.parent,this.columns),this.errorHandler.reject).then(e=>(delete this.promise,this.addItems(e,t,i,r)),this.errorHandler.reject);return this.promise=o.then(()=>this,this.errorHandler.reject),o}queueReload(){this.reloadQueued=!0,this.deferred=this.promiseService.defer(),this.promise=this.deferred.promise}updateColumns(e){const t=e(this.columns,!1);this.options.columns=t.request,this.columns=t}getAddedItems(e=!1){const t=this.initial,r=this.items,i=[];for(const n of r)-1===t.indexOf(n)&&i.push(e?n.itemId:n);return i}getRemovedItems(e=!1){const t=this.initial,r=this.items,i=[];for(const n of t)-1===r.indexOf(n)&&i.push(e?n.itemId:n);return i}getUpdatedItems(){const e=this.items,t=[];for(const r of e)!this.itemEntryService.isLocal(r)&&this.itemEntryService.hasChanges(r)&&t.push(r);return t}hasAddedItems(){return this.items.length>this.initial.length}hasRemovedItems(){return this.initial.length>this.items.length}hasUpdatedItems(){const e=this.items;for(const t of e)if(this.itemEntryService.hasChanges(t))return!0;return!1}getCurrentResource(){const e=this.resources;return e[e.length-1]}clearResources(e=!1){const t=this.items,r=this.resources,i=[];for(const e of t)this.itemEntryService.clearResources(e);for(const t of r){if(t.options[e?"clearOnSubTabChange":"clearOnTabChange"])continue;i.push(t);const r=t.items;for(const e of r)e.entry.resources.push(e)}this.resources=i}revertChanges(){const e=this.resources,t=this.getRemovedItems(),r=this.getAddedItems(!0);for(const i of e)i.addItemResources(t),i.removeItemResources(r);this.items=this.initial.slice()}onItemsCreated(e){const t=this.resources;for(const r of t)r.rebuildMap(),r.options.onItemsCreated(e)}getUpdatedItemColumns(e){const t=this.columns.item,r={};for(const i of t)void 0!==e[i.apiColumn.itemType]&&(r[i.id]=i);return r}}class ${constructor(e,t,r,i,n,s,o){this.errorHandler=e,this.collectionEntryService=t,this.itemRequestService=r,this.itemEntryService=i,this.keyService=n,this.queryService=s,this.promiseService=o}construct(e,t){return new z(this.errorHandler,this.collectionEntryService,this.itemRequestService,this.itemEntryService,this.keyService,this.queryService,this.promiseService,e,t)}}class G{constructor(e,t,r){this.itemResourceFactory=e,this.entry=t,this.options=r,this.columns=t.columns.response,this.itemIdMap={},this.items=[],t.resources.push(this),this.addItemResources(t.items)}getItemById(e){return this.itemIdMap[e]}rebuildMap(){const e=this.items,t={};for(const r of e)t[r.entry.itemId]=r;this.itemIdMap=t}addItemResources(e){if(0===e.length)return[];const t=[],r=this.options,i=this.items,n=this.itemIdMap,s=this.itemResourceFactory.getConstructor({edit:r.editItems,onChange:r.onChange,onDeactivate:r.onDeactivateItem});for(const r of e){const e=r.itemId;let o;void 0===n[e]?(o=s(r),i.push(o),n[e]=o):o=n[e],t.push(o)}return t}removeItemResources(e){const t=[];return function(e,t){const r=[];for(const i of e)t(i)&&r.push(i);if(r.length===e.length)return!1;e.splice(0);for(const t of r)e.push(t)}(this.items,r=>{for(const i of e)if(r.entry===i)return t.push(r),delete this.itemIdMap[i.itemId],!1;return!0}),t}callOnAdd(e){this.options.onAdd(e,this)}callOnRemove(e){this.options.onRemove(e,this)}forEach(e){const t=this.items;for(const r of t)e(r)}filter(e){const t=this.items,r=[];for(const i of t)e(i)&&r.push(i);return r}first(e){const t=this.items;for(const r of t)if(e(r))return r;return null}some(e){return null!==this.first(e)}groupBy(e){const t=this.items,r={};if("string"==typeof e)for(const i of t){const t=i.fields[e];void 0===r[t]&&(r[t]=[]),r[t].push(i)}if("function"==typeof e)for(const i of t){const t=e(i);null!==t&&(void 0===r[t]&&(r[t]=[]),r[t].push(i))}return r}map(e){const t=this.items,r=t.length,i=new Array(r);if("string"==typeof e)for(let n=0;n<r;n++)i[n]=t[n].fields[e];if("function"==typeof e)for(let n=0;n<r;n++)i[n]=e(t[n]);return i}reduce(e,t){const r=this.items;for(const i of r)t=e(i,t);return t}extend(e,t,r){return void 0===r&&(r=!0),this.entry.extend(e,this,r).then(e=>t?this.items:e)}deactivate(){this.options.onDeactivateCollection(this)}clearResource(){const e=this.entry.resources,t=this.items,r=e.indexOf(this);-1!==r&&e.splice(r,1);for(const e of t)e.clearResource()}}class Z extends G{constructor(e,t,r,i,n,s,o,c){super(r,o,c),this.errorHandler=e,this.itemHandler=t,this.changesProcessorFactory=i,this.keyService=n,this.promiseService=s}save(){if(!this.options.enableSave)throw new Error("collectionResourceService: Saving disabled");const e=this.entry,t=e.parent;return null!==t&&this.keyService.isLocalId(t.itemId)?this.promiseService.when():this.changesProcessorFactory.construct().execute([],[e])}moveItems(e,t,r){const i=this.entry,n=this.options;if(n.enableSave||n.modInstant)throw new Error("collectionResourceService: Cannot move items: saving enabled");if(i.itemType!==t.entry.itemType)throw new Error("collectionResourceService: Cannot move items: itemType mismatch");const s=i.removeItems(e,this,!1,r),o=[];for(const e of s)o.push(e.entry);return t.entry.addItems(o,t,!1,r),s}removeItems(e,t){void 0===t&&(t=!0);const r=this.entry.removeItems(e,this,!1,!1);return this.options.modInstant?this.save().then(()=>(t&&this.callOnRemove(r),r)):(t&&this.callOnRemove(r),this.promiseService.when(r))}removeItem(e,t){return this.removeItems([e],t).then(e=>e[0],this.errorHandler.reject)}addItems(e,t=!0){return this.itemHandler.fetchTemplate(this.entry.itemType).then(r=>{const i=[];let n;for(const t of e)i.push(this.itemHandler.createLocalEntry(this.keyService.getLocalId(),r,t.fields,t.derived));return n=this.entry.addItems(i,self,!1,!1),this.options.modInstant?this.save().then(e=>(t&&this.callOnAdd(n),n),this.errorHandler.reject):(t&&this.callOnAdd(n),n)},this.errorHandler.reject)}addItem(e,t){return this.addItems([e],t).then(e=>e[0],this.errorHandler.reject)}clear(e){return this.entry.clear(this,!1,e)}}class ee extends G{constructor(e,t,r,i,n,s,o,c){super(r,o,c),this.errorHandler=e,this.itemHandler=t,this.changesProcessorFactory=i,this.keyService=n,this.promiseService=s}}class te{constructor(e,t,r,i,n,s){this.errorHandler=e,this.itemHandler=t,this.itemResourceFactory=r,this.changesProcessorFactory=i,this.keyService=n,this.promiseService=s}construct(e,t){return new(t.editCollection?Z:ee)(this.errorHandler,this.itemHandler,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,this.promiseService,e,t)}}class re{constructor(e,t,r,i,n,s){if(this.columnHandler=e,this.columnSetFactory=t,this.columnUtil=r,this.itemType=i,this.requestColumns=n,this.responseColumns=s,this.expansionMap={},!0===n){this.requestColumnsTrue=!0,this.requestColumns=[];for(const e in s[i])this.requestColumns.push(e)}else this.requestColumnsTrue=!1}run(e,t){const r=e.id;return void 0!==this.expansionMap[r]?t?this.expansionMap[r]:this.expansionMap[r].merged:this.columnUtil.isColumnSubset(this.requestColumns,e.request,e.true)?t?null:e:(this.expansionMap[r]=this.expandColumnInfo(e),t?this.expansionMap[r]:this.expansionMap[r].merged)}expandColumnInfo(e){const t=this.columnUtil.mergeRequestColumns(e.request,this.requestColumns),r=this.columnUtil.mergeResponseColumns(e.response,this.responseColumns).merged,i=this.columnSetFactory.construct(this.itemType,t.merged,r),n=this.columnSetFactory.construct(this.itemType,t.difference,r,!1,!1);return i.true=this.requestColumnsTrue||e.true,{merged:i,difference:n}}}class ie{constructor(e,t,r){this.columnHandler=e,this.columnSetFactory=t,this.columnUtil=r}construct(e,t,r){return new re(this.columnHandler,this.columnSetFactory,this.columnUtil,e,t,r)}}let ne=0;class se{constructor(e,t,r,i,n,s=!0,o=!0){this.columnHandler=e,this.columnUtil=t,this.itemType=r,this.requestColumns=i,this.responseColumns=n,this.enableCaching=s,this.includeIdColumn=o,this.id=++ne,this.link=null,this.main=[],this.derived=[],this.root=[],this.leaf=[],this.formatted={main:[],derived:[]},this.filtered=[],this.custom=[],this.searchable=[],this.item=[],this.notItem=[],this.request=[],this.response={},this.true=!0===i,!0===i?this.processResponseColumns():this.processRequestColumns()}processResponseColumns(){this.request=[],this.response=this.enableCaching?this.columnHandler.setColumns(this.itemType,!0,this.responseColumns):this.responseColumns;for(const e in this.responseColumns[this.itemType])this.main.push(this.getColumnInfo(this.responseColumns[this.itemType][e],[],null)),this.request.push(e)}processRequestColumns(){if(this.request=this.requestColumns,this.response={},0!==this.requestColumns.length){for(const e of this.requestColumns){const t=this.getRequestColumnInfo(e,this.itemType,null);null!==t&&(this.main.push(t),t.isLeaf||this.root.push(t))}this.includeIdColumn&&void 0===this.response[this.itemType].id&&this.main.push(this.getRequestColumnInfo("id",this.itemType,null))}}getRequestColumnInfo(e,t,r){const i=this.columnUtil.parseRequestColumn(e),n=i.id;let s;if(void 0!==this.responseColumns[t]&&(s=this.responseColumns[t][n]),void 0===s)return console.warn("No api column for request column",n,"for itemType",t),null;this.enableCaching&&(s=this.columnHandler.setColumn(t,s));const o=this.response;return void 0===o[t]&&(o[t]={}),void 0===o[t][n]&&(o[t][n]=s),this.getColumnInfo(s,i.children,r)}getColumnInfo(e,t,r){const i=null!==r,n=e.id,s={id:n,path:i?r.path.concat(R,n):n,apiColumn:e,level:i?r.level+1:0,isLeaf:0===t.length,itemType:"",children:[],parent:null,tailPath:null};if(i?(this.derived.push(s),s.parent=r,s.tailPath=r.level>0?r.tailPath.concat(R,n):n):this[this.columnUtil.isItemColumn(e)?"item":"notItem"].push(s),this.columnUtil.isFormattedColumn(e)&&this.formatted[i?"derived":"main"].push(s),this.columnUtil.isFilteredColumn(e)&&this.filtered.push(s),this.columnUtil.isSearchableColumn(e)&&this.searchable.push(s),this.columnUtil.isCustomColumn(e)&&this.custom.push(s),"link"===e.type&&(this.link=e),0===t.length)return this.leaf.push(s),s;void 0===e.itemType&&console.warn("itemType undefined in column",e),s.itemType=e.itemType,s.children=[];for(const e of t){const t=this.getRequestColumnInfo(e,s.itemType,s);null!==t&&s.children.push(t)}return s}}class oe{constructor(e,t){this.columnHandler=e,this.columnUtil=t}construct(e,t,r,i=!0,n=!0){return new se(this.columnHandler,this.columnUtil,e,t,r,i,n)}}class ce{constructor(e,t,r,i,n,s,o=!1){this.collectionHandler=e,this.requestColumnExpansionFactory=t,this.itemEntryService=r,this.keyService=i,this.compilation=n,this.parameterMap=s,this.breakupByParent=o,this.requests=[]}finalizeRequest(e){const t=e.collections,r=e.columns;for(const e in t){const i=t[e];i.fitting.length>0&&r.expand(i.collection.columns)}return e.request.columns=r.get(),e}setRequestParent(e,t){const r=t.request;return"Void"!==e&&(r.parentType=e,r.parentId={},!0)}run(){if(this.breakupByParent)for(const e in this.compilation){const t=this.compilation[e];for(const r in t){if(this.keyService.isLocalId(r))continue;const i=this.initializeRequest();this.extendRequest(t[r],this.setRequestParent(e,i)?r:null,i),this.requests.push(this.finalizeRequest(i))}}else for(const e in this.compilation){const t=this.compilation[e],r=this.initializeRequest(),i=this.setRequestParent(e,r);let n=!1;for(const e in t)this.keyService.isLocalId(e)||(this.extendRequest(t[e],i?e:null,r),n=!0);n&&this.requests.push(this.finalizeRequest(r))}return this.requests}initializeRequest(){return{request:{requestType:"create",items:{}},columns:this.requestColumnExpansionFactory.construct(),items:{},collections:{}}}extendRequest(e,t,r){const i=r.request,n=r.items;for(const s in e){void 0===i.itemType&&(i.itemType=s),void 0===n[s]&&(n[s]={},i.items[s]={});for(const o in e[s]){const c=e[s][o],a=l(this.compilation,[s,o]),u=i.items[s][o]={},h=l(this.parameterMap,[s,o]);let m;if(null!==t&&(i.parentId[o]=t),r.columns.expand(c.columns),this.collectionHandler.expandCollectionMap(c,r.collections),n[s][o]=c,u.values=this.itemEntryService.formatRequest(c),u.parameters=h,void 0!==a){m=u.links={};for(const e in a){m[e]=[];for(const t in a[e])m[e].push(t)}this.extendRequest(a,null,r)}}}}}class ae{constructor(e,t,r,i){this.collectionHandler=e,this.requestColumnExpansionFactory=t,this.itemEntryService=r,this.keyService=i}construct(e,t,r=!1){return new ce(this.collectionHandler,this.requestColumnExpansionFactory,this.itemEntryService,this.keyService,e,t,r)}}class ue{constructor(e,t){this.queryMatcherFactory=e,this.itemEntryService=t,this.entries={}}some(e){for(const t in this.entries)for(const r in this.entries[t])if(e(this.entries[t][r]))return!0;return!1}getByItemType(e){const t=[];if(void 0===this.entries[e])return t;for(const r in this.entries[e])t.push(this.entries[e][r]);return t}getByQuery(e,t){const r=[];if(void 0===this.entries[e])return r;for(const i in this.entries[e]){const n=this.entries[e][i];this.matchQuery(n,t)&&r.push(n)}return r}getLocalByQuery(e,t){const r=[];if(void 0===this.entries[e])return r;for(const i in this.entries[e]){const n=this.entries[e][i];this.itemEntryService.isLocal(n)&&this.matchQuery(n,t)&&r.push(n)}return r}forEach(e){for(const t in this.entries)for(const r in this.entries[t])e(this.entries[t][r])}toArray(){const e=[];for(const t in this.entries)for(const r in this.entries[t])e.push(this.entries[t][r]);return e}add(e){const t=e.itemType;return void 0===this.entries[t]&&(this.entries[t]={}),this.entries[t][e.itemId]=e}get(e,t){return void 0===this.entries[e]?void 0:this.entries[e][t]}getByParent(e,t,r){const i=[];if(void 0===this.entries[r])return i;for(const n in this.entries[r]){const s=this.entries[r][n],o=s.parent;void 0!==o&&e===o.itemType&&t==o.itemId&&i.push(s)}return i}contains(e,t){return void 0!==this.entries[e]&&void 0!==this.entries[e][t]}updateItemId(e,t){const r=this.entries[e.itemType];return delete r[t],r[e.itemId]=e}clear(e){return void 0===e?(this.entries={},!0):void 0!==this.entries[e.itemType]&&delete this.entries[e.itemType][e.itemId]}matchQuery(e,t){const r=void 0!==e.parent?e.parent:{};return!0===this.queryMatcherFactory.construct(r.itemType,r.itemId,this.itemEntryService.getFields(e)).matchQuery(t.object)}}class le{constructor(e,t){this.queryMatcherFactory=e,this.itemEntryService=t}construct(){return new ue(this.queryMatcherFactory,this.itemEntryService)}}let he=0;class me{constructor(e,t,r,i={},n={},s=[]){this.itemType=e,this.itemId=t,this.columns=r,this.initial=i,this.derived=n,this.resources=s,this.parent=null,this.deferRequest=!1,this.entryId=++he}}class de{constructor(){}construct(e,t,r,i={},n={},s=[]){return new me(e,t,r,i,n,s)}}class pe{constructor(e,t,r){this.itemEntryService=e,this.entry=t,this.options=r,this.derived=t.derived,this.columns=t.columns.response[t.columns.itemType],t.resources.push(this)}isLocal(){return this.itemEntryService.isLocal(this.entry)}clearResource(){const e=this.entry.resources,t=e.indexOf(this);-1!==t&&e.splice(t,1)}deactivate(){this.options.onDeactivate(this)}}class fe extends pe{constructor(e,t,r){super(e,t,r),e.setModified(t),this.fields=t.modified}}class ye extends pe{constructor(e,t,r){super(e,t,r),this.fields=void 0===t.modified?t.initial:t.modified}}class ve{constructor(e,t){this.itemEntryService=e,this.itemResourceService=t}getConstructor(e){const t=(e=this.itemResourceService.processOptions(e)).edit?fe:ye;return r=>new t(this.itemEntryService,r,e)}construct(e,t){return new(t.edit?fe:ye)(this.itemEntryService,e,t)}}const ge={};class Se{constructor(e,t,r,i){this.itemEntryService=e,this.rootItemEntry=t,this.singleItemCache=r,this.collectionCache=i}process(){this.parentMap=this.createParentMap(this.singleItemCache),this.processItems(this.rootItemEntry.itemType,[this.rootItemEntry],{})}createParentMap(e){const t={};return e.forEach(e=>{const r=e.itemType,i=e.parent;if(void 0===i)return;const n=i.itemType,s=i.itemId;void 0===t[n]&&(t[n]={});let o=t[n];void 0===o[s]&&(o[s]={}),void 0===(o=o[s])[r]&&(o[r]=[]),o[r].push(e)}),t}processItems(e,t,r){void 0===this.destination[e]&&(this.destination[e]={}),void 0===r[e]&&(r[e]=[]);for(const i of t){const t=i.itemId;void 0===this.destination[e][t]&&(r[e].push(t),this.destination[e][t]=this.processItem(i))}}processItem(e){const t=e.itemType,r=e.itemId,i=this.getItemsByParent(t,r),n=this.collectionCache.getCollectionsByParent(t,r),o=this.itemEntryService.formatRequest(e),c={};for(const e in i)this.processItems(e,i[e],c);for(const e of n)null===e.options.query&&this.processItems(e.itemType,e.items,c);const a=s(o),u=s(c);return a&&u?{values:o,links:c}:a?{values:o}:u?{links:c}:ge}getItemsByParent(e,t){const r=this.parentMap[e];return void 0===r?{}:void 0===r[t]?{}:r[t]}}class Ce{constructor(e){this.itemEntryService=e}construct(e,t,r){return new Se(this.itemEntryService,e,t,r)}}const Ie="maybe";class Ee{constructor(e,t,r,i,n){this.apiFormatter=e,this.parentType=t,this.parentId=r,this.fields=i,this.itemType=n}compareValues(e,t){return i.isMoment(t)?this.apiFormatter.compareMomentObjects(t,e):i.isDuration(t)?this.apiFormatter.compareDurations(t,e):t==e}matchQuery(e){if(void 0!==e.search)return Ie;if(void 0!==e.custom)return Ie;if(void 0!==e.linkedTo)return this.matchLinkedToQuery(e);if(void 0!==e.conditions)return this.matchComplexQuery(e);if(void 0!==e.key)return this.matchSimpleQuery(this.fields[e.key],e);if(!s(e))return!0;throw new Error("queryMatcher: Unsupported query! Parsed?")}matchLinkedToQuery(e){if(e.reverse)return Ie;let t;return(t=e.linkedTo===this.parentType&&this.matchSimpleQuery(this.parentId,e.query))===Ie?Ie:e.not?!t:t}matchComplexQuery(e){const t=e.conditions;let r,i;switch(e.operator){case"AND":r=!0,i=!1;break;case"OR":r=!1,i=!0;break;default:throw new Error("queryMatcher: Unsupported operator")}for(const e of t){const t=this.matchQuery(e);if(t===i)return i;t===Ie&&(r=Ie)}return r}matchSimpleQuery(e,t){const r=t.key;let n=t.value;if(!s(t))return!0;if(void 0===e)return console.warn("Required field",r,"not found for",this.itemType),Ie;switch("NOW"===n&&(n=i()),t.comparator){case"=":return this.compareValues(e,n);case"!=":return!this.compareValues(e,n);case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"IN":return c(e,n);case"NOT IN":return!c(e,n);default:throw new Error("queryMatcher: Unsupported comparator: "+t.comparator+" in query "+t)}}}class Re{constructor(e){this.apiFormatter=e}construct(e,t,r,i){return new Ee(this.apiFormatter,e,t,r,i)}}var qe;!function(e){e[e.OBJ=0]="OBJ",e[e.STR=1]="STR",e.SEP=":"}(qe||(qe={}));class Te{constructor(e,t){this.query=e,this.parameters=t}processValue(e){return Array.isArray(e)?e.slice().sort():i.isMoment(e)?i(e):i.isDuration(e)?i.duration(e):e}compareParsedQueries(e,t){return e[qe.STR]===t[qe.STR]?0:e[qe.STR]>t[qe.STR]?1:-1}parse(e=this.query){if(void 0!==e.linkedTo)return this.parseLinkedToQuery(e.linkedTo,e.query,e.reverse,e.not);if(void 0!==e.not)throw new Error('queryParser: "Not" not supported');if(void 0!==e.custom)return this.parseCustomQuery(e.custom,e.parameters);if(void 0!==e.search)return this.parseSearchQuery(e.search);if(void 0!==e.conditions)return this.parseComplexQuery(e.conditions,e.operator);if(void 0!==e.key)return this.parseSimpleQuery(e.key,e.value,e.comparator);if(!s(e))return[{},"{}"];const t=o(e);return this.parseSimpleQuery(t,e[t])}parseSearchQuery(e){return[{search:(e=this.formatValue(e))[qe.OBJ]},"[search"+qe.SEP+e[qe.STR]+"]"]}parseCustomQuery(e,t){if(void 0===t)return[{custom:e},"["+e+"]"];const r=this.parseCustomParameters(t);return[{custom:e,parameters:r[qe.OBJ]},"["+e+qe.SEP+r[qe.STR]+"]"]}parseCustomParameters(e){const t=Object.keys(e).sort(),r={};let i="";for(let n=0;n<t.length;n++){const s=t[n],o=this.formatValue(e[s]);r[s]=o[qe.OBJ],n>0&&(i+=qe.SEP),i+=o[qe.STR]}return[r,i]}parseSimpleQuery(e,t,r){return t=this.formatValue(t),void 0===r&&(r=Array.isArray(t[qe.OBJ])?"IN":"="),[{key:e,value:t[qe.OBJ],comparator:r},"["+r+qe.SEP+e+qe.SEP+t[qe.STR]+"]"]}parseLinkedToQuery(e,t,r,i){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===i&&(i=!1);const n=this.parse(t);return[{linkedTo:e,query:n[qe.OBJ],reverse:r,not:i},"[linkedTo"+qe.SEP+e+qe.SEP+n[qe.STR]+qe.SEP+r+qe.SEP+i+"]"]}parseComplexQuery(e,t){t=void 0===t?"AND":t.toUpperCase();const r=this.parseConditions(e);return[{conditions:r[qe.OBJ],operator:t},"["+t+r[qe.STR]+"]"]}parseConditions(e){let t=[];const r=[];let i="";for(const r of e)t.push(this.parse(r));t=t.sort(this.compareParsedQueries);for(const e of t)r.push(e[qe.OBJ]),i+=e[qe.STR];return[r,i]}formatValue(e){let t;if("string"==typeof e&&"&"===e.charAt(0)){const 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]}}class Fe{constructor(){}construct(e,t){return new Te(e,t)}}class be{constructor(e){this.columnUtil=e,this.columns={},this.columnInfoIdMap={}}expand(e){if(this.columnInfoIdMap[e.id])return;const t=e.itemType;void 0===this.columns[t]&&(this.columns[t]=[]),this.columns[t]=this.columnUtil.mergeRequestColumns(this.columns[t],e.request).merged,this.columnInfoIdMap[e.id]=!0}get(){return this.columns}}class ke{constructor(e){this.columnUtil=e}construct(){return new be(this.columnUtil)}}class we{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m,d){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=i,this.columnHandler=n,this.lockService=s,this.itemResourceFactory=o,this.collectionCacheFactory=c,this.changesProcessorFactory=a,this.itemCacheFactory=u,this.collectionResourceFactory=l,this.itemEntryService=h,this.itemResourceService=m,this.promiseService=d,this.collectionOptions={},this.tabRequestParameters={},this.callbacks={onBeforeSave:{},onSaveSuccess:{},onSaveWithoutClosing:{}},this._hasChanges=!1,this.collections=this.collectionCacheFactory.construct(),this.deferredCollections=this.collectionCacheFactory.construct(),this.items=this.itemCacheFactory.construct()}addSingleItem(e,t,r){return r&&(this.rootItem=e),this.items.contains(e.itemType,e.itemId)||this.items.add(e),(t=this.itemResourceService.processOptions(t)).onDeactivate=this.clearItem,this.itemResourceFactory.construct(e,t)}addCollection(e,t){this.collections.contains(e)||this.collections.add(e);const r=e.id;if(void 0===this.collectionOptions[r])this.collectionOptions[r]={edit:t.editCollection,editItems:t.editItems};else{const e=this.collectionOptions[r];e.edit=e.edit||t.editCollection,e.editItems=e.editItems||t.editItems}return t.onDeactivateItem=this.clearItem,t.onDeactivateCollection=this.clearCollection,this.collectionResourceFactory.construct(e,t)}clearCollection(e){const t=e.entry;this.collections.clear(t),t.clearResources()}clearItem(e){const t=e.entry;this.items.clear(t),this.itemEntryService.clearResources(t)}clearResources(e=!1){this.items.forEach(this.itemEntryService.clearResources),this.collections.forEach(t=>{t.clearResources(e)}),e||this.collections.clear()}updateSingleItems(e){for(const t in e)for(const r in e[t]){const e=this.items.get(t,r);void 0!==e&&this.items.updateItemId(e,r)}}revertChanges(){this.items.forEach(this.itemEntryService.resetModified),this.collections.forEach(this.resetCollection)}resetCollection(e){const t=this.collectionOptions[e.id];if(t.edit&&e.revertChanges(),t.editItems)for(const t of e.items)this.itemEntryService.resetModified(t)}hasChanges(){return this._hasChanges||(this._hasChanges=this.detectChanges()),this._hasChanges}detectChanges(){return!!this.items.some(this.itemEntryService.hasChanges)||this.collections.some(e=>{this.collectionHasChanges(e)})}collectionHasChanges(e){const t=this.collectionOptions[e.id];return!(!t.edit||!e.hasAddedItems()&&!e.hasRemovedItems())||t.editItems&&e.hasUpdatedItems()}isLockable(){return void 0!==this.rootItem&&this.itemEntryService.isLockable(this.rootItem)}save(e=!1,t,r,i){return(this.isLockable()?this.lockService.fetchLock(this.rootItem):this.promiseService.when()).then(t=>this.executeCallbacks("onBeforeSave",e),this.errorHandler.reject).then(()=>{const e=h({},this.tabRequestParameters,t);return this.tabRequestParameters={},this.changesProcessorFactory.construct().execute(this.items.toArray(),this.collections.toArray(),r,e,this.collectionOptions,i)},this.errorHandler.reject).then(t=>(this.isLockable()&&this.lockService.clearLock(this.rootItem),this._hasChanges=!1,e||this.updateSingleItems(t),this.executeCallbacks("onSaveSuccess",t).then(()=>(e||this.executeCallbacks("onSaveWithoutClosing",t),t),this.errorHandler.reject)),this.errorHandler.reject)}executeCallbacks(e,t){const r={};for(const i in this.callbacks[e])r[i]=this.callbacks[e][i](t);return this.promiseService.all(r)}enableChangesWatcher(){null!==this.changesInterval&&(console.warn("Changes watcher already running!",this),this.disableChangesWatcher()),this.changesInterval=setInterval(()=>{this.hasChanges()&&(this.disableChangesWatcher(),this.isLockable()&&this.lockService.fetchLock(this.rootItem))},3e3)}enableWatcher(){this.enableChangesWatcher()}disableChangesWatcher(){clearInterval(this.changesInterval),this.changesInterval=null}disableWatcher(){this.disableChangesWatcher()}registerCallback(e,t,r){return this.callbacks[e][t]=r,()=>{delete this.callbacks[e][t]}}}class Oe{constructor(e,t,r,i,n,s,o,c,a,u,l,h,m,d){this.apiRequestService=e,this.errorHandler=t,this.itemHandler=r,this.collectionHandler=i,this.columnHandler=n,this.lockService=s,this.itemResourceFactory=o,this.collectionCacheFactory=c,this.changesProcessorFactory=a,this.itemCacheFactory=u,this.collectionResourceFactory=l,this.itemEntryService=h,this.itemResourceService=m,this.promiseService=d}construct(){return new we(this.apiRequestService,this.errorHandler,this.itemHandler,this.collectionHandler,this.columnHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemEntryService,this.itemResourceService,this.promiseService)}}r.d(t,"default",function(){return je}),r.d(t,"noop",function(){return He}),r.d(t,"identity",function(){return xe}),r.d(t,"ViewResource",function(){return ye}),r.d(t,"EditResource",function(){return fe}),r.d(t,"ENTRY_STATUS",function(){return E}),r.d(t,"COLUMN_SEPERATOR",function(){return R}),r.d(t,"RENDER_AS_SEPERATOR",function(){return q});class je{constructor(e,t,r,i){this.promiseService=new U,this.apiFormatter=new C,this.keyService=new D,this.queryService=new _,this.columnUtil=new w,this.itemEntryService=new j(this.apiFormatter,this.keyService,this.promiseService),this.itemResourceService=new M(this.itemEntryService),this.lockService=new P(e,i,this.keyService,this.promiseService),this.queryMatcherFactory=new Re(this.apiFormatter),this.itemCacheFactory=new le(this.queryMatcherFactory,this.itemEntryService),this.batchStatusFactory=new V(this.promiseService),this.columnCache=new b(this.columnUtil),this.columnHandler=new k(e,i,this.promiseService,this.columnCache,this.columnUtil),this.columnSetFactory=new oe(this.columnHandler,this.columnUtil),this.columnExpansionFactory=new ie(this.columnHandler,this.columnSetFactory,this.columnUtil),this.itemEntryFactory=new de,this.itemHandler=new H(e,r,i,this.itemEntryFactory,this.columnHandler,this.itemCacheFactory,this.batchStatusFactory,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryService,this.apiFormatter,this.keyService,this.promiseService,this.columnUtil),this.itemRequestService=new x(e,i,this.itemHandler,this.columnHandler,this.columnExpansionFactory,this.columnSetFactory,this.itemEntryService,this.queryService,this.promiseService),this.queryParserFactory=new Fe,this.collectionEntryService=new I(this.queryParserFactory,this.queryService),this.collectionResourceService=new F,this.collectionEntryFactory=new $(i,this.collectionEntryService,this.itemRequestService,this.itemEntryService,this.keyService,this.queryService,this.promiseService),this.collectionCacheFactory=new K(this.queryMatcherFactory),this.collectionHandler=new T(i,this.itemRequestService,this.itemHandler,this.columnHandler,this.collectionEntryFactory,this.collectionCacheFactory,this.queryParserFactory,this.collectionEntryService,this.columnSetFactory,this.itemEntryService,this.keyService,this.promiseService,this.queryService,this.columnUtil),this.requestColumnExpansionFactory=new ke(this.columnUtil),this.createRequestFactory=new ae(this.collectionHandler,this.requestColumnExpansionFactory,this.itemEntryService,this.keyService),this.changesCompilerFactory=new Q(this.itemEntryService),this.changesProcessorFactory=new W(e,i,this.itemHandler,this.collectionHandler,this.columnHandler,this.changesCompilerFactory,this.createRequestFactory,this.columnExpansionFactory,this.requestColumnExpansionFactory,this.collectionEntryService,this.itemEntryService,this.apiFormatter,this.promiseService),this.itemResourceFactory=new ve(this.itemEntryService,this.itemResourceService),this.collectionResourceFactory=new te(i,this.itemHandler,this.itemResourceFactory,this.changesProcessorFactory,this.keyService,this.promiseService),this.resourceCacheFactory=new Oe(e,i,this.itemHandler,this.collectionHandler,this.columnHandler,this.lockService,this.itemResourceFactory,this.collectionCacheFactory,this.changesProcessorFactory,this.itemCacheFactory,this.collectionResourceFactory,this.itemEntryService,this.itemResourceService,this.promiseService),this.moduleChangesCompilerFactory=new Ce(this.itemEntryService),this.itemAdministrator=new O(e,t,r,i,this.itemHandler,this.collectionHandler,this.columnSetFactory,this.itemRequestService,this.resourceCacheFactory,this.moduleChangesCompilerFactory,this.collectionEntryService,this.collectionResourceService,this.itemEntryService,this.keyService,this.queryService)}}function He(){}function xe(e){return e}},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var i,n,s,o,c,a=1,u={},l=!1,h=e.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(e);m=m&&m.setTimeout?m:e,"[object process]"==={}.toString.call(e.process)?i=function(e){t.nextTick(function(){p(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?(o="setImmediate$"+Math.random()+"$",c=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(o)&&p(+t.data.slice(o.length))},e.addEventListener?e.addEventListener("message",c,!1):e.attachEvent("onmessage",c),i=function(t){e.postMessage(o+t,"*")}):e.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){p(e.data)},i=function(e){s.port2.postMessage(e)}):h&&"onreadystatechange"in h.createElement("script")?(n=h.documentElement,i=function(e){var t=h.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,n.removeChild(t),t=null},n.appendChild(t)}):i=function(e){setTimeout(p,0,e)},m.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var n={callback:e,args:t};return u[a]=n,i(a),a++},m.clearImmediate=d}function d(e){delete u[e]}function p(e){if(l)setTimeout(p,0,e);else{var t=u[e];if(t){l=!0;try{!function(e){var t=e.callback,i=e.args;switch(i.length){case 0:t();break;case 1:t(i[0]);break;case 2:t(i[0],i[1]);break;case 3:t(i[0],i[1],i[2]);break;default:t.apply(r,i)}}(t)}finally{d(e),l=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,r(2),r(3))},function(e,t,r){(function(e){var i=void 0!==e&&e||"undefined"!=typeof self&&self||window,n=Function.prototype.apply;function s(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new s(n.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new s(n.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(5),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(2))}])});
29
29
  //# sourceMappingURL=rm-core.js.map