Socket
Socket
Sign inDemoInstall

redux-orm

Package Overview
Dependencies
7
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.16.0 to 0.16.1

7

CHANGELOG.md
**Minor changes before v1.0.0 can include breaking changes.**
### 0.16.0
* Removed unnecessary branches ([#316](https://github.com/redux-orm/redux-orm/pull/316))
* Optimized `objectShallowEquals` using `every` instead of `forEach` ([#317](https://github.com/redux-orm/redux-orm/pull/317))
This release should not be breaking. It is a new minor version only to safeguard from potential edge cases.
### 0.15.1

@@ -4,0 +11,0 @@

2

dist/redux-orm.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ReduxOrm",[],t):"object"==typeof exports?exports.ReduxOrm=t():e.ReduxOrm=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=33)}([function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t,n){var r=n(14),s=n(15),o=n(16);e.exports=function(e){return r(e)||s(e)||o()}},function(e,t,n){"use strict";function r(e,t){return e===t}function s(e,t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var r=t.length,s=0;s<r;s++)if(!e(t[s],n[s]))return!1;return!0}function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,n=null,o=null;return function(){return s(t,n,arguments)||(o=e.apply(null,arguments)),n=arguments,o}}function i(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var n=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+n+"]")}return t}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(){for(var t=arguments.length,r=Array(t),s=0;s<t;s++)r[s]=arguments[s];var a=0,c=r.pop(),u=i(r),l=e.apply(void 0,[function(){return a++,c.apply(null,arguments)}].concat(n)),d=o((function(){for(var e=[],t=u.length,n=0;n<t;n++)e.push(u[n].apply(null,arguments));return l.apply(null,e)}));return d.resultFunc=c,d.recomputations=function(){return a},d.resetRecomputations=function(){return a=0},d}}t.__esModule=!0,t.defaultMemoize=o,t.createSelectorCreator=a,t.createStructuredSelector=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;if("object"!=typeof e)throw new Error("createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);var n=Object.keys(e);return t(n.map((function(t){return e[t]})),(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t,r){return e[n[r]]=t,e}),{})}))};var c=t.createSelector=a(o)},function(e,t,n){!function(e,t){"use strict";function n(e){return"string"==typeof e||"number"==typeof e}var r=function(){function e(){this._cache={}}var t=e.prototype;return t.set=function(e,t){this._cache[e]=t},t.get=function(e){return this._cache[e]},t.remove=function(e){delete this._cache[e]},t.clear=function(){this._cache={}},t.isValidCacheKey=function(e){return n(e)},e}(),s=r,o=function(){return!0};function i(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return function(e,r){if("function"==typeof r)throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');var i={};"function"==typeof e?Object.assign(i,r,{keySelector:e}):Object.assign(i,e);var a=0,c=n.pop(),u=Array.isArray(n[0])?n[0]:[].concat(n);n.push((function(){return a++,c.apply(void 0,arguments)}));var l=i.cacheObject||new s,d=i.selectorCreator||t.createSelector,h=l.isValidCacheKey||o;i.keySelectorCreator&&(i.keySelector=i.keySelectorCreator({keySelector:i.keySelector,inputSelectors:u,resultFunc:c}));var f=function(){var e=i.keySelector.apply(i,arguments);if(h(e)){var t=l.get(e);return void 0===t&&(t=d.apply(void 0,n),l.set(e,t)),t.apply(void 0,arguments)}console.warn('[re-reselect] Invalid cache key "'+e+'" has been returned by keySelector function.')};return f.getMatchingSelector=function(){var e=i.keySelector.apply(i,arguments);return l.get(e)},f.removeMatchingSelector=function(){var e=i.keySelector.apply(i,arguments);l.remove(e)},f.clearCache=function(){l.clear()},f.resultFunc=c,f.dependencies=u,f.cache=l,f.recomputations=function(){return a},f.resetRecomputations=function(){return a=0},f.keySelector=i.keySelector,f}}function a(e){if(void 0===e)throw new Error('Missing the required property "cacheSize".');if(!Number.isInteger(e)||e<=0)throw new Error('The "cacheSize" property must be a positive integer value.')}var c=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache={},this._cacheOrdering=[],this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache[e]=t,this._cacheOrdering.push(e),this._cacheOrdering.length>this._cacheSize){var n=this._cacheOrdering[0];this.remove(n)}},t.get=function(e){return this._cache[e]},t.remove=function(e){var t=this._cacheOrdering.indexOf(e);t>-1&&this._cacheOrdering.splice(t,1),delete this._cache[e]},t.clear=function(){this._cache={},this._cacheOrdering=[]},t.isValidCacheKey=function(e){return n(e)},e}(),u=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache={},this._cacheOrdering=[],this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache[e]=t,this._registerCacheHit(e),this._cacheOrdering.length>this._cacheSize){var n=this._cacheOrdering[0];this.remove(n)}},t.get=function(e){return this._registerCacheHit(e),this._cache[e]},t.remove=function(e){this._deleteCacheHit(e),delete this._cache[e]},t.clear=function(){this._cache={},this._cacheOrdering=[]},t._registerCacheHit=function(e){this._deleteCacheHit(e),this._cacheOrdering.push(e)},t._deleteCacheHit=function(e){var t=this._cacheOrdering.indexOf(e);t>-1&&this._cacheOrdering.splice(t,1)},t.isValidCacheKey=function(e){return n(e)},e}(),l=function(){function e(){this._cache=new Map}var t=e.prototype;return t.set=function(e,t){this._cache.set(e,t)},t.get=function(e){return this._cache.get(e)},t.remove=function(e){this._cache.delete(e)},t.clear=function(){this._cache.clear()},e}(),d=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache=new Map,this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache.set(e,t),this._cache.size>this._cacheSize){var n=this._cache.keys().next().value;this.remove(n)}},t.get=function(e){return this._cache.get(e)},t.remove=function(e){this._cache.delete(e)},t.clear=function(){this._cache.clear()},e}(),h=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache=new Map,this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache.set(e,t),this._cache.size>this._cacheSize){var n=this._cache.keys().next().value;this.remove(n)}},t.get=function(e){var t=this._cache.get(e);return this._cache.has(e)&&(this.remove(e),this._cache.set(e,t)),t},t.remove=function(e){this._cache.delete(e)},t.clear=function(){this._cache.clear()},e}();e.FifoCacheObject=c,e.FifoMapCache=d,e.FifoObjectCache=c,e.FlatCacheObject=r,e.FlatMapCache=l,e.FlatObjectCache=r,e.LruCacheObject=h,e.LruMapCache=h,e.LruObjectCache=u,e.createStructuredCachedSelector=function(e){return t.createStructuredSelector(e,i)},e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}(t,n(4))},function(e,t,n){var r=n(17),s=n(7),o=n(18),i=n(19),a=n(20),c=n(21),u=n(8);e.exports=function(e,t,n){var l=-1;t=r(t.length?t:[u],a(s));var d=o(e,(function(e,n,s){return{criteria:r(t,(function(t){return t(e)})),index:++l,value:e}}));return i(d,(function(e,t){return c(e,t,n)}))}},function(e,t){e.exports=function(e){return e}},function(e,t){e.exports=function(e){return e}},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,s=0,o=[];++n<r;){var i=e[n];t(i,n,e)&&(o[s++]=i)}return o}},function(e,t,n){var r=n(6),s=n(9);e.exports=function(e,t,n,o){return null==e?[]:(s(t)||(t=null==t?[]:[t]),s(n=o?void 0:n)||(n=null==n?[]:[n]),r(e,t,n))}},function(e,t,n){var r=n(24),s=n(25),o=n(7),i=n(9),a=n(26);e.exports=function(e,t){return(i(e)?r:s)(e,a(o(t,3)))}},function(e,t,n){var r=n(27),s=n(6),o=n(28),i=n(32),a=o((function(e,t){if(null==e)return[];var n=t.length;return n>1&&i(e,t[0],t[1])?t=[]:n>2&&i(t[0],t[1],t[2])&&(t=[t[0]]),s(e,r(t,1),[])}));e.exports=a},function(e,t){e.exports=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}},function(e,t){e.exports=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,s=Array(r);++n<r;)s[n]=t(e[n],n,e);return s}},function(e,t){e.exports=function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){var r=n(22);e.exports=function(e,t,n){for(var s=-1,o=e.criteria,i=t.criteria,a=o.length,c=n.length;++s<a;){var u=r(o[s],i[s]);if(u)return s>=c?u:u*("desc"==n[s]?-1:1)}return e.index-t.index}},function(e,t,n){var r=n(23);e.exports=function(e,t){if(e!==t){var n=void 0!==e,s=null===e,o=e==e,i=r(e),a=void 0!==t,c=null===t,u=t==t,l=r(t);if(!c&&!l&&!i&&e>t||i&&a&&u&&!c&&!l||s&&a&&u||!n&&u||!o)return 1;if(!s&&!i&&!l&&e<t||l&&n&&o&&!s&&!i||c&&n&&o||!a&&o||!u)return-1}return 0}},function(e,t){e.exports=function(){return!1}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,s=0,o=[];++n<r;){var i=e[n];t(i,n,e)&&(o[s++]=i)}return o}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,s=0,o=[];++n<r;){var i=e[n];t(i,n,e)&&(o[s++]=i)}return o}},function(e,t){var n="Expected a function";e.exports=function(e){if("function"!=typeof e)throw new TypeError(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}},function(e,t){e.exports=function(e){return e&&e.length?e[0]:void 0}},function(e,t,n){var r=n(8),s=n(29),o=n(31);e.exports=function(e,t){return o(s(e,t,r),e+"")}},function(e,t,n){var r=n(30),s=Math.max;e.exports=function(e,t,n){return t=s(void 0===t?e.length-1:t,0),function(){for(var o=arguments,i=-1,a=s(o.length-t,0),c=Array(a);++i<a;)c[i]=o[t+i];i=-1;for(var u=Array(t+1);++i<t;)u[i]=o[i];return u[t]=n(c),r(e,this,u)}}},function(e,t){e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t){e.exports=function(e){return e}},function(e,t){e.exports=function(){return!1}},function(e,t,n){"use strict";n.r(t);var r=n(0),s=n.n(r),o=n(3),i=n.n(o),a=n(2),c=n.n(a);function u(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function l(e){return function t(n){return 0===arguments.length||u(n)?t:e.apply(this,arguments)}}function d(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(e){return t.apply(this,arguments)};case 2:return function(e,n){return t.apply(this,arguments)};case 3:return function(e,n,r){return t.apply(this,arguments)};case 4:return function(e,n,r,s){return t.apply(this,arguments)};case 5:return function(e,n,r,s,o){return t.apply(this,arguments)};case 6:return function(e,n,r,s,o,i){return t.apply(this,arguments)};case 7:return function(e,n,r,s,o,i,a){return t.apply(this,arguments)};case 8:return function(e,n,r,s,o,i,a,c){return t.apply(this,arguments)};case 9:return function(e,n,r,s,o,i,a,c,u){return t.apply(this,arguments)};case 10:return function(e,n,r,s,o,i,a,c,u,l){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function h(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return u(n)?t:l((function(t){return e(n,t)}));default:return u(n)&&u(r)?t:u(n)?l((function(t){return e(t,r)})):u(r)?l((function(t){return e(n,t)})):e(n,r)}}}var f=h((function(e,t){return 1===e?l(t):d(e,function e(t,n,r){return function(){for(var s=[],o=0,i=t,a=0;a<n.length||o<arguments.length;){var c;a<n.length&&(!u(n[a])||o>=arguments.length)?c=n[a]:(c=arguments[o],o+=1),s[a]=c,u(c)||(i-=1),a+=1}return i<=0?r.apply(this,s):d(i,e(t,s,r))}}(e,[],t))})),p=l((function(e){return f(e.length,e)})),m={"@@functional/placeholder":!0};function y(e,t){for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)}var g="@@_______immutableOpsOwnerID";function b(e,t){return!!t&&e[g]===t}var w="function"==typeof Symbol?function(){return Symbol("ownerID")}:function(){return{}};function v(e,t){return t&&function(e,t){Object.defineProperty(e,g,{value:t,configurable:!0,enumerable:!1})}(e,t),e}function _(e){return e instanceof Array?e:[e]}var M=".";function O(e){return"string"==typeof e?-1===e.indexOf(M)?[e]:e.split(M):e}function N(e,t,n){return n[e]=t,n}function S(e,t,n){var r=_(t);return e?r.forEach((function(t){y(t,(function(t,r){var s;e&&n.hasOwnProperty(r)?(s="object"===c()(t)?S(e,[t],n[r]):t,n[r]=s):n[r]=t}))})):Object.assign.apply(Object,[n].concat(i()(r))),n}var k=S.bind(null,!1),E=S.bind(null,!0);function j(e,t){return _(e).forEach((function(e){delete t[e]})),t}function x(e,t,n){return e[n]!==t[n]}function F(e,t,n,r){if(b(r,t))return S(e,n,r);var s=_(n),o=!1,i=r,a=function(){o||(o=!0,v(i=Object.assign({},r),t))};return s.forEach((function(n){y(n,(function(s,o){if(e&&r.hasOwnProperty(o)){var u=i[o];if("object"===c()(s)&&!(s instanceof Array)){if(x(i,n,o)){var l=F(e,t,s,u);l!==u&&(a(),i[o]=l)}return!0}}x(i,n,o)&&(a(),i[o]=s)}))})),i}var C=F.bind(null,!0);function A(e,t,n,r){if(b(r,e))return N(t,n,r);if(r[t]===n)return r;var s=function(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}(r);return s[t]=n,v(s,e),s}function I(e,t){for(var n=0,r=0;n<t.length;){e(t[n],r)?n++:t.splice(n,1),r++}return t}function R(e,t,n,r){var s=_(n);return r.splice.apply(r,[e,t].concat(i()(s))),r}function D(e,t,n){return R(e,0,t,n)}function $(e,t,n,r,s){if(b(s,e))return R(t,n,r,s);var o=_(r),a=s.slice();return v(a,e),a.splice.apply(a,[t,n].concat(i()(o))),a}function T(e,t,n,r){return b(r,e)?D(t,n,r):$(e,t,0,n,r)}var P={merge:F.bind(null,!1),deepMerge:C,omit:function(e,t,n){if(b(n,e))return j(t,n);var r=_(t).filter((function(e){return n.hasOwnProperty(e)}));if(0===r.length)return n;var s=Object.assign({},n);return r.forEach((function(e){delete s[e]})),v(s,e),s},setIn:function(e,t,n,r){var s=O(t),o=function(e,t){for(var n=O(e),r=t,s=0;s<n.length;s++){var o=r[n[s]];if(s===n.length-1)return o;if("object"!==c()(o))return;r=o}}(s,r);if(n===o)return r;var i,a=s.length,u=i=b(r,e)?r:Object.assign(v({},e),r);return s.forEach((function(t,r){if(r!==a-1){var o=i[t],u=c()(o);if("object"!==u){if("undefined"===u){var l=v({},e);return i[t]=l,void(i=l)}var d="".concat(s[r-1],".").concat(t);throw new Error("A non-object value was encountered when traversing setIn path at ".concat(d,"."))}if(b(o,e))i=o;else{var h=v({},e);i[t]=Object.assign(h,o),i=h}}else i[t]=n})),u},insert:T,push:function(e,t,n){return T(e,n.length,t,n)},filter:function(e,t,n){if(b(n,e))return I(t,n);var r=n.filter(t);return r.length===n.length?n:(v(r,e),r)},splice:$,set:function(e,t,n,r){if(function(e){return e&&"object"===c()(e)&&"number"==typeof e.length&&e.length>=0&&e.length%1==0}(r))return A(e,t,n,r);if(b(r,e))return N(t,n,r);if(r[t]===n)return r;var s=Object.assign({},r);return v(s,e),s[t]=n,s}},B={merge:k,deepMerge:E,omit:j,setIn:function(e,t,n){for(var r=O(e),s=r.length,o=!1,i=0,a=n,u=r[i];!o;)if(i===s-1)a[u]=t,o=!0;else{var l=c()(a[u]);if("undefined"===l){var d={};v(d,null),a[u]=d}else if("object"!==l){var h="".concat(r[i-1],".").concat(u);throw new Error("A non-object value was encountered when traversing setIn path at ".concat(h,"."))}a=a[u],u=r[++i]}return n},insert:D,push:function(e,t){var n=_(e);return t.push.apply(t,i()(n)),t},filter:I,splice:R,set:N};var V=function(){var e=Object.assign({},P);y(e,(function(t,n){e[n]=p(t.bind(null,null))}));var t=Object.assign({},B);y(t,(function(e,n){t[n]=p(e)}));var n=Object.assign({},P);return y(n,(function(e,t){n[t]=p(e)})),Object.assign(e,{mutable:t,batch:n,batched:function(e,t){var n,r;"function"==typeof e?(r=e,n=w()):(n=e,r=t);var s=Object.assign({},P);return y(s,(function(e,t){s[t]=p(e.bind(null,n))})),r(s)},__:m,getBatchToken:w})}();const U="REDUX_ORM_UPDATE",q="REDUX_ORM_DELETE",z="REDUX_ORM_CREATE",L="REDUX_ORM_FILTER",Q="REDUX_ORM_EXCLUDE",X="SUCCESS",H=Symbol("REDUX_ORM_ALL_INSTANCES"),Y=(e,t)=>void 0===t?H:t;function K(e){return("function"==typeof console.warn?console.warn.bind(console):console.log.bind(console))(e)}function G(e,t){return e+((n=t).charAt(0).toUpperCase()+n.slice(1));var n}function J(e){return`from${e}Id`}function W(e){return`to${e}Id`}function Z(e){return function(...t){return this.getQuerySet()[e](...t)}}function ee(e){return function(){return this.getQuerySet()[e]}}function te(e,t){const n=t.sharedMethods.slice();!function(e,t){let n=e;for(;n!==Function.prototype;)t(n),n=Object.getPrototypeOf(n)}(t,t=>{for(let r=0;r<n.length;r++){let s=!1;const o=n[r],i=Object.getOwnPropertyDescriptor(t.prototype,o);void 0!==i&&(void 0!==i.get?(i.get=ee(o),Object.defineProperty(e,o,i)):e[o]=Z(o),s=!0),s&&n.splice(r--,1)}})}function ne(e){return null!=e&&"function"==typeof e.getId?e.getId():e}const{getBatchToken:re}=V;function se({type:e,payload:t},n){if(e!==L)return!1;if("object"!=typeof t)return!1;if(!t.hasOwnProperty(n))return!1;const r=t[n];return null!==r&&void 0!==r}function oe(e,t){return Object.entries(e).reduce((e,[n,r])=>(e[n]=t(r),e),{})}function ie(e){return e&&"string"!=typeof e?e.modelName:e}const ae=function(){function e(e,t,n){Object.assign(this,{modelClass:e,clauses:t||[]}),this._opts=n}e.addSharedMethod=function(e){this.sharedMethods=this.sharedMethods.concat(e)};var t=e.prototype;return t._new=function(e,t){const n={...this._opts,...t};return new this.constructor(this.modelClass,e,n)},t.toString=function(){return this._evaluate(),`QuerySet contents:\n - ${this.rows.map(({id:e})=>this.modelClass.withId(e).toString()).join("\n - ")}`},t.toRefArray=function(){return this._evaluate()},t.toModelArray=function(){const{modelClass:e}=this;return this._evaluate().map(t=>new e(t))},t.count=function(){return this._evaluate(),this.rows.length},t.exists=function(){return Boolean(this.count())},t.at=function(e){const{modelClass:t}=this,n=this._evaluate();if(e>=0&&e<n.length)return new t(n[e])},t.first=function(){return this.at(0)},t.last=function(){const e=this._evaluate();return this.at(e.length-1)},t.all=function(){return this._new(this.clauses)},t.filter=function(e){const t="object"==typeof e?oe(e,ne):e,n={type:L,payload:t};return this._new(this.clauses.concat(n))},t.exclude=function(e){const t="object"==typeof e?oe(e,ne):e,n={type:Q,payload:t};return this._new(this.clauses.concat(n))},t._evaluate=function(){if(void 0===this.modelClass.session)throw new Error([`Tried to query the ${this.modelClass.modelName} model's table without a session. `,"Create a session using `session = orm.session()` and use ",`\`session["${this.modelClass.modelName}"]\` for querying instead.`].join(""));if(!this._evaluated){const{session:e,modelName:t}=this.modelClass,n={table:t,clauses:this.clauses};this.rows=e.query(n).rows,this._evaluated=!0}return this.rows},t.orderBy=function(e,t){const n={type:"REDUX_ORM_ORDER_BY",payload:[e,t]};return this._new(this.clauses.concat(n))},t.update=function(e){const{session:t,modelName:n}=this.modelClass;t.applyUpdate({action:U,query:{table:n,clauses:this.clauses},payload:e}),this._evaluated=!1},t.delete=function(){const{session:e,modelName:t}=this.modelClass;this.toModelArray().forEach(e=>e._onDelete()),e.applyUpdate({action:q,query:{table:t,clauses:this.clauses}}),this._evaluated=!1},t.map=function(){throw new Error("`QuerySet.prototype.map` has been removed. Call `.toModelArray()` or `.toRefArray()` first to map.")},t.forEach=function(){throw new Error("`QuerySet.prototype.forEach` has been removed. Call `.toModelArray()` or `.toRefArray()` first to iterate.")},s()(e,[{key:"withModels",get:function(){throw new Error("`QuerySet.prototype.withModels` has been removed. Use `.toModelArray()` or predicate functions that instantiate Models from refs, e.g. `new Model(ref)`.")}},{key:"withRefs",get:function(){K("`QuerySet.prototype.withRefs` has been deprecated. Query building operates on refs only now.")}}]),e}();ae.sharedMethods=["count","at","all","last","first","filter","exclude","orderBy","update","delete"];var ce=ae;var ue=function(){function e(e,t,n,r,s){this.schema=e,this.db=t,this.state=n||t.getEmptyState(),this.initialState=this.state,this.withMutations=Boolean(r),this.batchToken=s||w(),this.modelData={},this.models=e.getModelClasses(),this.sessionBoundModels=this.models.map(e=>{function t(){return Reflect.construct(e,arguments,t)}return Reflect.setPrototypeOf(t.prototype,e.prototype),Reflect.setPrototypeOf(t,e),Object.defineProperty(this,e.modelName,{get:()=>t}),t.connect(this),t})}var t=e.prototype;return t.getDataForModel=function(e){return this.modelData[e]||(this.modelData[e]={}),this.modelData[e]},t.getModelData=function(){return this.modelData},t.markAccessed=function(e,t){const n=this.getDataForModel(e);n.accessedInstances||(n.accessedInstances={}),t.forEach(e=>{n.accessedInstances[e]=!0})},t.markFullTableScanned=function(e){this.getDataForModel(e).fullTableScanned=!0},t.markAccessedIndexes=function(e){e.forEach(([e,t,n])=>{const r=this.getDataForModel(e);r.accessedIndexes||(r.accessedIndexes={}),r.accessedIndexes[t]=[...r.accessedIndexes[t]||[],n]})},t.applyUpdate=function(e){const t=this._getTransaction(e),n=this.db.update(e,t,this.state),{status:r,state:s,payload:o}=n;if(r!==X)throw new Error(`Applying update failed with status ${r}. Payload: ${o}`);return this.state=s,o},t.query=function(e){const t=this.db.query(e,this.state);return this._markAccessedByQuery(e,t),t},t._getTransaction=function(e){const{withMutations:t}=this,{action:n}=e;let{batchToken:r}=this;return[U,q].includes(n)&&(r=w()),{batchToken:r,withMutations:t}},t._markAccessedByQuery=function(e,t){const{table:n,clauses:r}=e,{rows:s}=t,{idAttribute:o}=this[n],i=new Set(s.map(e=>e[o])),a=r.some(e=>!!se(e,o)&&(i.add(e.payload[o]),!0)),c=[],{indexes:u}=this.state[n];r.forEach(e=>{Object.keys(u).forEach(t=>{if(!se(e,t))return;const r=e.payload[t];c.push([n,t,r])})}),a?this.markAccessed(n,i):c.length?(this.markAccessed(n,i),this.markAccessedIndexes(c)):this.markFullTableScanned(n)},t.getNextState=function(){return K("`Session.prototype.getNextState` has been deprecated. Access the `Session.prototype.state` property instead."),this.state},t.reduce=function(){throw new Error("`Session.prototype.reduce` has been removed. The Redux integration API is now decoupled from ORM and Session - see the 0.9 migration guide in the GitHub repo.")},s()(e,[{key:"accessedModelInstances",get:function(){return Object.entries(this.getModelData()).reduce((e,[t,n])=>(n.accessedInstances&&(e[t]=n.accessedInstances),e),{})}},{key:"fullTableScannedModels",get:function(){return Object.entries(this.getModelData()).reduce((e,[t,n])=>(n.fullTableScanned&&e.push(t),e),[])}},{key:"accessedIndexes",get:function(){return Object.entries(this.getModelData()).reduce((e,[t,n])=>(n.accessedIndexes&&(e[t]=n.accessedIndexes),e),{})}}]),e}(),le=n(1),de=n.n(le);var he=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.installForwardsDescriptor=function(){Object.defineProperty(this.model.prototype,this.fieldName,this.field.createForwardsDescriptor(this.fieldName,this.model,this.toModel,this.throughModel))},n.installForwardsVirtualField=function(){this.model.virtualFields[this.fieldName]=this.field.createForwardsVirtualField(this.fieldName,this.model,this.toModel,this.throughModel)},n.installBackwardsDescriptor=function(){if(Object.getOwnPropertyDescriptor(this.toModel.prototype,this.backwardsFieldName))throw new Error((e=this.model.modelName,t=this.fieldName,n=this.toModel.modelName,[`Reverse field ${this.backwardsFieldName} already defined`,` on model ${n}. To fix, set a custom related`,` name on ${e}.${t}.`].join("")));var e,t,n;Object.defineProperty(this.toModel.prototype,this.backwardsFieldName,this.field.createBackwardsDescriptor(this.fieldName,this.model,this.toModel,this.throughModel))},n.installBackwardsVirtualField=function(){this.toModel.virtualFields[this.backwardsFieldName]=this.field.createBackwardsVirtualField(this.fieldName,this.model,this.toModel,this.throughModel)},t}(function(){function e(e){this.field=e.field,this.fieldName=e.fieldName,this.model=e.model,this.orm=e.orm,this.field.references(this.model)&&(this.field.toModelName="this")}return e.prototype.run=function(){this.installForwardsDescriptor(),this.field.installsForwardsVirtualField&&this.installForwardsVirtualField(),this.field.installsBackwardsDescriptor&&this.installBackwardsDescriptor(),this.field.installsBackwardsVirtualField&&this.installBackwardsVirtualField()},s()(e,[{key:"toModel",get:function(){if(void 0===this._toModel){const{toModelName:e}=this.field;this._toModel=e?"this"===e?this.model:this.orm.get(e):null}return this._toModel}},{key:"throughModel",get:function(){if(void 0===this._throughModel){const e=this.field.getThroughModelName(this.fieldName,this.model);this._throughModel=e?this.orm.get(e):null}return this._throughModel}},{key:"backwardsFieldName",get:function(){return this.field.getBackwardsFieldName(this.model)}}]),e}());var fe=function(){function e(){}var t=e.prototype;return t.getClass=function(){return this.constructor},t.references=function(e){return!1},t.getThroughModelName=function(e,t){return null},s()(e,[{key:"installerClass",get:function(){return he}},{key:"installsForwardsVirtualField",get:function(){return!1}},{key:"installsBackwardsDescriptor",get:function(){return!1}},{key:"installsBackwardsVirtualField",get:function(){return!1}},{key:"index",get:function(){return!1}}]),e}();function pe(e,t){return{get(){const{session:{[t]:n}}=this.getClass(),{[e]:r}=this._fields;return n.withId(r)},set(t){this.update({[e]:ne(t)})}}}function me(e,t,n,r,s){return{get(){const{session:{[e]:o,[t]:i,[n]:a}}=this.getClass(),c=s?i:o,u=s?o:i,l=s?r.to:r.from,d=s?r.from:r.to,h=this.getId(),f=a.filter({[l]:h}),p=new Set(f.toRefArray().map(e=>e[d])),m=u.filter(e=>p.has(e[u.idAttribute]));return m.add=function(...e){const t=new Set(e.map(ne)),n=f.filter(e=>t.has(e[d]));if(n.exists()){const e=n.toRefArray().map(e=>e[d]);throw new Error(`Tried to add already existing ${u.modelName} id(s) ${e} to the ${c.modelName} instance with id ${h}`)}t.forEach(e=>{a.create({[d]:e,[l]:h})})},m.clear=function(){f.delete()},m.remove=function(...e){const t=new Set(e.map(ne)),n=f.filter(e=>t.has(e[d]));if(n.count()!==t.size){const e=n.toRefArray().map(e=>e[d]),r=[...t].filter(t=>!e.includes(t));throw new Error(`Tried to delete non-existing ${u.modelName} id(s) ${r} from the ${c.modelName} instance with id ${h}`)}n.delete()},m},set(){throw new Error("Tried setting a M2M field. Please use the related QuerySet methods add, remove and clear.")}}}var ye=function(e){function t(t){var n;return(n=e.call(this)||this).opts=t||{},n.opts.hasOwnProperty("getDefault")&&(n.getDefault=n.opts.getDefault),n}return de()(t,e),t.prototype.createForwardsDescriptor=function(e,t){return function(e){return{get(){return this._fields[e]},set(t){return this.set(e,t)},enumerable:!0,configurable:!0}}(e)},t}(fe);var ge=function(e){function t(...t){var n;if(n=e.call(this)||this,1===t.length&&"object"==typeof t[0]){const e=t[0];n.toModelName=ie(e.to),n.relatedName=e.relatedName,n.through=ie(e.through),n.throughFields=e.throughFields,n.as=e.as}else[n.toModelName,n.relatedName]=[ie(t[0]),t[1]];return n}de()(t,e);var n=t.prototype;return n.getBackwardsFieldName=function(e){return this.relatedName||e.modelName.toLowerCase()+"Set"},n.createBackwardsVirtualField=function(e,t,n,r){return new(this.getClass())(t.modelName,e)},n.references=function(e){return this.toModelName===e.modelName},s()(t,[{key:"installsBackwardsVirtualField",get:function(){return!0}},{key:"installsBackwardsDescriptor",get:function(){return!0}},{key:"installerClass",get:function(){return function(e){function t(){return e.apply(this,arguments)||this}return de()(t,e),t.prototype.installForwardsDescriptor=function(){Object.defineProperty(this.model.prototype,this.field.as||this.fieldName,this.field.createForwardsDescriptor(this.fieldName,this.model,this.toModel,this.throughModel))},t}(he)}}]),t}(fe);var be=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.createForwardsDescriptor=function(e,t,n,r){return pe(e,n.modelName)},n.createBackwardsDescriptor=function(e,t,n,r){return s=e,o=t.modelName,{get(){const{session:{[o]:e}}=this.getClass();return e.filter({[s]:this.getId()})},set(){throw new Error("Can't mutate a reverse many-to-one relation.")}};var s,o},s()(t,[{key:"index",get:function(){return!0}}]),t}(ge);var we=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.getDefault=function(){return[]},n.getThroughModelName=function(e,t){return this.through||G(t.modelName,e)},n.createForwardsDescriptor=function(e,t,n,r){return me(t.modelName,n.modelName,r.modelName,this.getThroughFields(e,t,n,r),!1)},n.createBackwardsDescriptor=function(e,t,n,r){return me(t.modelName,n.modelName,r.modelName,this.getThroughFields(e,t,n,r),!0)},n.createBackwardsVirtualField=function(e,t,n,r){return new(this.getClass())({to:t.modelName,relatedName:e,through:r.modelName,throughFields:this.getThroughFields(e,t,n,r)})},n.createForwardsVirtualField=function(e,t,n,r){return new(this.getClass())({to:n.modelName,relatedName:e,through:this.through,throughFields:this.getThroughFields(e,t,n,r),as:this.as})},n.getThroughFields=function(e,t,n,r){if(this.throughFields){const[e,t]=this.throughFields,s=r.fields[e];return{to:s.references(n)?e:t,from:s.references(n)?t:e}}if(t.modelName===n.modelName)return{to:W(n.modelName),from:J(t.modelName)};const s=e=>Object.keys(r.fields).find(t=>r.fields[t].references(e));return{to:s(n),from:s(t)}},s()(t,[{key:"installsForwardsVirtualField",get:function(){return!0}}]),t}(ge);var ve=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.getBackwardsFieldName=function(e){return this.relatedName||e.modelName.toLowerCase()},n.createForwardsDescriptor=function(e,t,n,r){return function(...e){return pe(...e)}(e,n.modelName)},n.createBackwardsDescriptor=function(e,t,n,r){return s=e,o=t.modelName,{get(){const{session:{[o]:e}}=this.getClass();return e.get({[s]:this.getId()})},set(){throw new Error("Can't mutate a reverse one-to-one relation.")}};var s,o},t}(ge);function _e(e){return new ye(e)}function Me(...e){return new be(...e)}function Oe(...e){return new we(...e)}function Ne(...e){return new ve(...e)}function Se(e){const t=e.getClass(),{idAttribute:n,modelName:r}=t;return{table:r,clauses:[{type:L,payload:{[n]:e.getId()}}]}}const ke=function(){function e(e){this._initFields(e)}var t=e.prototype;return t._initFields=function(e){const t=Object(e);this._fields={...t},Object.keys(t).forEach(e=>{e in this||Object.defineProperty(this,e,{get:()=>this._fields[e],set:t=>this.set(e,t),configurable:!0,enumerable:!0})})},e.toString=function(){return`ModelClass: ${this.modelName}`},e.options=function(){return{}},e.markAccessed=function(e){if(void 0===this._session)throw new Error([`Tried to mark rows of the ${this.modelName} model as accessed without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].markAccessed\` instead.`].join(""));this.session.markAccessed(this.modelName,e)},e.markFullTableScanned=function(){if(void 0===this._session)throw new Error([`Tried to mark the ${this.modelName} model as full table scanned without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].markFullTableScanned\` instead.`].join(""));this.session.markFullTableScanned(this.modelName)},e.markAccessedIndexes=function(e){if(void 0===this._session)throw new Error([`Tried to mark indexes for the ${this.modelName} model as accessed without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].markAccessedIndexes\` instead.`].join(""));this.session.markAccessedIndexes(e.map(([e,t])=>[this.modelName,e,t]))},e.connect=function(e){if(!(e instanceof ue))throw new Error("A model can only be connected to instances of Session.");this._session=e},e.getQuerySet=function(){const{querySetClass:e}=this;return new e(this)},e.invalidateClassCache=function(){this.isSetUp=void 0,this.virtualFields={}},e.tableOptions=function(){return"function"==typeof this.backend?(K("`Model.backend` has been deprecated. Please rename to `.options`."),this.backend()):this.backend?(K("`Model.backend` has been deprecated. Please rename to `.options`."),this.backend):"function"==typeof this.options?this.options():this.options},e.create=function(e){if(void 0===this._session)throw new Error([`Tried to create a ${this.modelName} model instance without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].create\` instead.`].join(""));const t={...e},n={},r=Object.keys(this.fields),s=Object.keys(this.virtualFields);r.forEach(r=>{const s=this.fields[r],o=e.hasOwnProperty(r);if(s instanceof we)o&&(n[r]=e[r],s.as||delete t[r]);else if(o){const n=e[r];t[r]=ne(n)}else s.getDefault&&(t[r]=s.getDefault())}),s.forEach(r=>{if(!n.hasOwnProperty(r)){const s=this.virtualFields[r];e.hasOwnProperty(r)&&s instanceof we&&(n[r]=e[r],delete t[r])}});const o=new this(this.session.applyUpdate({action:z,table:this.modelName,payload:t}));return o._refreshMany2Many(n),o},e.upsert=function(e){if(void 0===this.session)throw new Error([`Tried to upsert a ${this.modelName} model instance without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].upsert\` instead.`].join(""));const{idAttribute:t}=this;if(e.hasOwnProperty(t)){const n=e[t];if(this.idExists(n)){const t=this.withId(n);return t.update(e),t}}return this.create(e)},e.withId=function(e){return this.get({[this.idAttribute]:e})},e.idExists=function(e){return this.exists({[this.idAttribute]:e})},e.exists=function(e){if(void 0===this.session)throw new Error([`Tried to check if a ${this.modelName} model instance exists without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].exists\` instead.`].join(""));return Boolean(this._findDatabaseRows(e).length)},e.get=function(e){const t=this._findDatabaseRows(e);if(0===t.length)return null;if(t.length>1)throw new Error(`Expected to find a single row in \`${this.modelName}.get\`. Found ${t.length}.`);return new this(t[0])},t.getClass=function(){return this.constructor},t.getId=function(){return this._fields[this.getClass().idAttribute]},e._findDatabaseRows=function(e){const t={table:this.modelName};return e&&(t.clauses=[{type:L,payload:e}]),this.session.query(t).rows},t.toString=function(){const e=this.getClass();return`${e.modelName}: {${Object.keys(e.fields).map(t=>{if(e.fields[t]instanceof we){return`${t}: [${this[t].toModelArray().map(e=>e.getId()).join(", ")}]`}return`${t}: ${this._fields[t]}`}).join(", ")}}`},t.equals=function(e){return function(e,t){const n=Object.entries(Object(e));return n.length===Object.keys(t).length&&n.every(([e,n])=>t.hasOwnProperty(e)&&t[e]===n)}(this._fields,e._fields)},t.set=function(e,t){this.update({[e]:t})},t.update=function(e){const t=this.getClass();if(void 0===t.session)throw new Error([`Tried to update a ${t.modelName} model instance without a session. `,"You cannot call `.update` on an instance that you did not receive from the database."].join(""));const n={...e},{fields:r,virtualFields:s}=t,o={};for(const e in n){if(r.hasOwnProperty(e)){const t=r[e];t instanceof be||t instanceof ve?n[e]=ne(n[e]):t instanceof we&&(o[e]=n[e],t.as||delete n[e])}else if(s.hasOwnProperty(e)){s[e]instanceof we&&(o[e]=n[e],delete n[e])}}const i={...this._fields,...n},a=new t(i);this.equals(a)||(this._initFields(i),t.session.applyUpdate({action:U,query:Se(this),payload:n})),this._refreshMany2Many(o)},t.refreshFromState=function(){this._initFields(this.ref)},t.delete=function(){const e=this.getClass();if(void 0===e.session)throw new Error([`Tried to delete a ${e.modelName} model instance without a session. `,"You cannot call `.delete` on an instance that you did not receive from the database."].join(""));this._onDelete(),e.session.applyUpdate({action:q,query:Se(this)})},t._refreshMany2Many=function(e){const t=this.getClass(),{fields:n,virtualFields:r,modelName:s}=t;Object.keys(e).forEach(o=>{const i=!n.hasOwnProperty(o),a=r[o],c=e[o];if(!Array.isArray(c))throw new TypeError(`Failed to resolve many-to-many relationship: ${s}[${o}] must be an array (passed: ${c})`);const u=c.map(ne),l=[...new Set(u)];if(u.length!==l.length)throw new Error(`Found duplicate id(s) when passing "${u}" to ${t.modelName}.${o} value`);const d=a.through||G(t.modelName,o),h=t.session[d];let f,p;i?({from:p,to:f}=a.throughFields):({from:f,to:p}=a.throughFields);const m=function(e,t){const n=e.filter(e=>t.includes(e)),r=e.filter(e=>!n.includes(e)),s=t.filter(e=>!n.includes(e));return r.length||s.length?{delete:r,add:s}:null}(h.filter(e=>e[f]===this[t.idAttribute]).toRefArray().map(e=>e[p]),u);if(m){const{delete:e,add:t}=m;e.length>0&&this[a.as||o].remove(...e),t.length>0&&this[a.as||o].add(...t)}})},t._onDelete=function(){const{virtualFields:e}=this.getClass();for(const t in e){const n=e[t];if(n instanceof we)this[t].clear();else if(n instanceof be){const e=this[t];e.exists()&&e.update({[n.relatedName]:null})}else n instanceof ve&&null!==this[t]&&(this[t][n.relatedName]=null)}},e.hasId=function(e){return console.warn("`Model.hasId` has been deprecated. Please use `Model.idExists` instead."),this.idExists(e)},t.getNextState=function(){throw new Error("`Model.prototype.getNextState` has been removed. See the 0.9 migration guide on the GitHub repo.")},s()(e,[{key:"ref",get:function(){const e=this.getClass();return e._findDatabaseRows({[e.idAttribute]:this.getId()})[0]}}],[{key:"idAttribute",get:function(){if(void 0===this._session)throw new Error([`Tried to get the ${this.modelName} model's id attribute without a session. `,"Create a session using `session = orm.session()` and access ",`\`session["${this.modelName}"].idAttribute\` instead.`].join(""));return this.session.db.describe(this.modelName).idAttribute}},{key:"session",get:function(){return this._session}},{key:"query",get:function(){return this.getQuerySet()}}]),e}();ke.fields={id:_e()},ke.virtualFields={},ke.querySetClass=ce;var Ee=ke,je=n(10),xe=n.n(je),Fe=n(11),Ce=n.n(Fe),Ae=n(12),Ie=n.n(Ae),Re=n(13),De=n.n(Re);const $e={idAttribute:"id",arrName:"items",mapName:"itemsById",fields:{}};var Te=function(){function e(e){Object.assign(this,$e,e)}var t=e.prototype;return t.accessId=function(e,t){return e[this.mapName][t]},t.accessIds=function(e,t){const n=e[this.mapName];return t.map(e=>n[e])},t.idExists=function(e,t){return e[this.mapName].hasOwnProperty(t)},t.accessIdList=function(e){return e[this.arrName]},t.accessList=function(e){return this.accessIds(e,this.accessIdList(e))},t.getMaxId=function(e){return this.getMeta(e,"maxId")},t.setMaxId=function(e,t,n){return this.setMeta(e,t,"maxId",n)},t.nextId=function(e){return e+1},t.getEmptyState=function(){return{...{[this.arrName]:[],[this.mapName]:{}},indexes:Object.keys(this.fields).filter(e=>e!==this.idAttribute).filter(e=>this.fields[e].index).reduce((e,t)=>({...e,[t]:{}}),{}),meta:{}}},t.setMeta=function(e,t,n,r){const{batchToken:s,withMutations:o}=e;if(o){return V.mutable.setIn(["meta",n],r,t)}return V.batch.setIn(s,["meta",n],r,t)},t.getMeta=function(e,t){return e.meta[t]},t.query=function(e,t){if(0===t.length)return this.accessList(e);const{idAttribute:n}=this,r=De()(t,e=>se(e,n)?1:function({type:e}){return[L,Q].includes(e)}(e)?2:3),s=(t,r)=>{const{type:o,payload:i}=r;if(!t){if(se(r,n)){const t=i[n],o=Object.keys(i).reduce((e,t)=>(t!==n&&(e[t]=i[t]),e),{}),a=this.idExists(e,t)?[t]:[];return Object.keys(o).length?s(this.accessIds(e,a),{...r,payload:o}):this.accessIds(e,a)}if(o===L&&"object"==typeof i){const t=Object.entries(e.indexes),n=[],o=[];if(t.forEach(([e,t])=>{se(r,e)&&t.hasOwnProperty(i[e])&&(n.push(t[i[e]]),o.push(e))}),n.length){const t=n.pop(),a=n.reduce((e,t)=>{const n=new Set(t);return e.filter(Set.prototype.has,n)},t),c=Object.keys(i).reduce((e,t)=>(o.includes(t)||(e[t]=i[t]),e),{});return Object.keys(c).length?s(this.accessIds(e,a),{...r,payload:c}):this.accessIds(e,a)}}return s(this.accessList(e),r)}switch(o){case L:return xe()(t,i);case Q:return Ie()(t,i);case"REDUX_ORM_ORDER_BY":{const[e,n]=i;return Ce()(t,e,function(e){if(void 0===e)return;const t=e=>["desc",!1].includes(e)?"desc":"asc";return Array.isArray(e)?e.map(t):t(e)}(n))}default:return t}};return r.reduce(s,void 0)},t.insert=function(e,t,n){const{batchToken:r,withMutations:s}=e,o=n.hasOwnProperty(this.idAttribute);let i=t;const[a,c]=function(e,t){let n,r,s=e;return void 0===s&&(s=-1),void 0===t?(n=s+1,r=n):(n=Math.max(s+1,t),r=t),[n,r]}(this.getMaxId(t),n[this.idAttribute]);i=this.setMaxId(e,t,a);const u=o?n:V.batch.set(r,this.idAttribute,c,n),l=Object.keys(i.indexes).filter(e=>n.hasOwnProperty(e)&&null!==n[e]).map(e=>[e,n[e]]);if(s)return V.mutable.push(c,i[this.arrName]),V.mutable.set(c,u,i[this.mapName]),l.forEach(([e,t])=>{const n=i.indexes[e];n.hasOwnProperty(t)?V.mutable.push(c,n[t]):V.mutable.set(t,[c],n)}),{state:i,created:u};const d=V.batch.merge(r,l.reduce((e,[t,n])=>(e[t]=V.batch.merge(r,{[n]:V.batch.push(r,c,e[t][n]||[])},e[t]),e),{...i.indexes}),i.indexes);return{state:V.batch.merge(r,{[this.arrName]:V.batch.push(r,c,i[this.arrName]),[this.mapName]:V.batch.merge(r,{[c]:u},i[this.mapName]),indexes:d},i),created:u}},t.update=function(e,t,n,r){const{batchToken:s,withMutations:o}=e,i=o?V.mutable.set:V.batch.set(s),a=Object.keys(t.indexes).filter(e=>r.hasOwnProperty(e)),c=[],u=[],l=n.reduce((e,t)=>{const n=a.reduce((e,n)=>({...e,[n]:t[n]}),{}),l=(e=>{return(o?V.mutable.merge:V.batch.merge(s))(r,e)})(t),d=a.reduce((e,t)=>({...e,[t]:l[t]}),{}),h=l[this.idAttribute],f=i(h,l,e);return a.forEach(e=>{const{[e]:t}=n,{[e]:r}=d;t!==r&&(null!==t&&u.push([e,t,h]),null!==r&&c.push([e,r,h]))}),f},t[this.mapName]);let d=t.indexes;return o?(u.forEach(([e,t,n])=>{const r=d[e][t],s=r.indexOf(n);V.mutable.splice(s,1,[],r)}),c.forEach(([e,t,n])=>{V.mutable.push(n,d[e][t])})):(c.length&&(d=V.batch.merge(s,c.reduce((e,[t,n,r])=>(e[t]=V.batch.merge(s,{[n]:V.batch.push(s,r,e[t][n]||[])},e[t]),e),{...d}),d)),u.length&&(d=V.batch.merge(s,u.reduce((e,[t,n,r])=>(e[t]=V.batch.merge(s,{[n]:V.batch.filter(s,e=>e!==r,e[t][n])},e[t]),e),{...d}),d))),V.batch.merge(s,{[this.mapName]:l,indexes:d},t)},t.delete=function(e,t,n){const{batchToken:r,withMutations:s}=e,{arrName:o,mapName:i}=this,a=t[o],c=n.map(e=>e[this.idAttribute]);if(s)return c.forEach(e=>{const n=a.indexOf(e);V.mutable.splice(n,1,[],a),V.mutable.omit(e,t[i])}),Object.values(t.indexes).forEach(e=>Object.values(e).forEach(e=>c.forEach(t=>{const n=e.indexOf(t);-1!==n&&V.mutable.splice(n,1,[],e)}))),t;const u=V.batch.merge(r,Object.entries(t.indexes).reduce((e,[t,n])=>(e[t]=V.batch.merge(r,Object.entries(n).reduce((e,[t,n])=>(e[t]=V.batch.filter(r,e=>!c.includes(e),n),e),{...e[t]}),e[t]),e),{...t.indexes}),t.indexes);return V.batch.merge(r,{[o]:V.batch.filter(r,e=>!c.includes(e),t[o]),[i]:V.batch.omit(r,c,t[i]),indexes:V.batch.merge(r,u,t.indexes)},t)},e}();const Pe={};function Be(e,t,n){const{table:r,clauses:s}=t;return{rows:e[r].query(n[r],s)}}function Ve(e,t,n,r){const{action:s,payload:o}=t;let i,a,c;if(s===z){({table:i}=t);const s=e[i],u=r[i],l=s.insert(n,u,o);a=l.state,c=l.created}else{const{query:u}=t;({table:i}=u);const{rows:l}=Be(e,u,r),d=e[i],h=r[i];if(s===U)a=d.update(n,h,l,o),c=Be(e,u,r).rows;else{if(s!==q)throw new Error(`Database received unknown update type: ${s}`);a=d.delete(n,h,l),c=l}}const u=function(e,t,n,r){const{batchToken:s,withMutations:o}=n;return o?(r[e]=t,r):V.batch.set(s,e,t,r)}(i,a,n,r);return{status:X,state:u,payload:c}}Object.defineProperty(Pe,"@@_______REDUX_ORM_STATE_FLAG",{enumerable:!0,value:!0});var Ue=function(e){const{tables:t}=e,n=Object.entries(t).reduce((e,[t,n])=>({...e,[t]:new Te(n)}),{});return{getEmptyState:()=>Object.entries(n).reduce((e,[t,n])=>({...e,[t]:n.getEmptyState()}),Pe),query:Be.bind(null,n),update:Ve.bind(null,n),describe:e=>n[e]}};let qe=function(){function e({parent:e,orm:t}){this._parent=e,this._orm=t,this.keySelector=Y}return s()(e,[{key:"cachePath",get:function(){return[...this._parent?this._parent.cachePath:[],this.key]}}]),e}(),ze=function(e){function t({model:t,...n}){var r;return(r=e.call(this,n)||this)._model=t,r}return de()(t,e),s()(t,[{key:"resultFunc",get:function(){return(e,t,...n)=>{const{[this._model.modelName]:r}=e;return void 0===t?r.all().toModelArray().map(t=>this.valueForInstance(t,e,...n)):Array.isArray(t)?t.map(t=>this.valueForInstance(r.withId(t),e,...n)):this.valueForInstance(r.withId(t),e,...n)}}}]),t}(qe);function Le(e,t){return t}let Qe=function(e){function t({field:t,selector:n,...r}){var s;return(s=e.call(this,r)||this)._field=t,s._selector=n,s}return de()(t,e),t.prototype.createResultFunc=function(e){return(t,...n)=>{const r=e(t,...n);if(null===r)return null;const s=this._orm.stateSelector(t,...n),o=this._orm.session(s),i=Le(t,...n),{[this._field.toModelName]:{idAttribute:a}}=o;return void 0===i||Array.isArray(i)?r.map(e=>null===e?null:this._selector(t,e[a])):this._selector(t,r[a])}},s()(t,[{key:"parent",get:function(){return this._parent}}]),t}(ze),Xe=function(e){function t({model:t,...n}){var r;return(r=e.call(this,n)||this)._model=t,r}return de()(t,e),s()(t,[{key:"key",get:function(){return this._model.modelName}},{key:"dependencies",get:function(){return[this._orm,Le]}},{key:"resultFunc",get:function(){return({[this._model.modelName]:e},t)=>{if(void 0===t)return e.all().toRefArray();if(Array.isArray(t))return t.map(t=>{const n=e.withId(t);return n?n.ref:null});const n=e.withId(t);return n?n.ref:null}}}]),t}(qe),He=function(e){function t({field:t,fieldModel:n,accessorName:r,isVirtual:s,...o}){var i;return(i=e.call(this,o)||this)._field=t,i._fieldModel=n,i._accessorName=r,i._isVirtual=s,i}de()(t,e);var n=t.prototype;return n.valueForInstance=function(e,t){if(!e)return null;let n;if(this._parent instanceof Xe)n=e[this._accessorName];else{const{[this._parent.toModelName]:r}=t,s=this._parent.valueForInstance(e,t),o=s?new r(s):null;n=o?o[this._accessorName]:null}return n instanceof Ee?n.ref:n instanceof ce?n.toRefArray():n},n.map=function(e){if(e instanceof Xe)throw this.toModelName===e._model.modelName?new Error(`Cannot select models in a \`map()\` call. If you just want the \`${this._accessorName}\` as a ref array then you can simply drop the \`map()\`. Otherwise make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`):new Error(`Cannot select \`${e._model.modelName}\` models in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`);if(e instanceof t||e instanceof Qe){if(this.toModelName!==e._model.modelName)throw new Error(`Cannot select fields of the \`${e._model.modelName}\` model in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`)}else if(!e||"function"!=typeof e||!e.recomputations)throw new Error(`\`map()\` requires a selector as an input. Received: ${JSON.stringify(e)} of type ${typeof e}`);if(!(this._field instanceof be||this._field instanceof we))throw new Error("Cannot map selectors for non-collection fields");return new Qe({parent:this,model:this._model,orm:this._orm,field:this._field,selector:e})},s()(t,[{key:"key",get:function(){return this._accessorName}},{key:"dependencies",get:function(){return[this._orm,Le]}},{key:"toModelName",get:function(){return"this"===this._field.toModelName?this._fieldModel.modelName:this._field.toModelName}}]),t}(ze);function Ye({parent:e,model:t,field:n,fieldModel:r,accessorName:s,orm:o,isVirtual:i}){const a=new He({parent:e,model:t,field:n,fieldModel:r,accessorName:s,orm:o,isVirtual:i});if(!(n instanceof ge))return a;if(e instanceof He&&(e._field instanceof be&&e._isVirtual||e._field instanceof we))throw new Error(`Cannot create a selector for \`${e._accessorName}.${s}\` because \`${e._accessorName}\` is a collection field.`);const{toModelName:c}=n,u=o.get("this"===c?t.modelName:c);return Object.entries(u.fields).forEach(([e,n])=>{const r=n.as||e;Object.defineProperty(a,r,{get:()=>Ye({parent:a,model:t,fieldModel:u,field:n,accessorName:r,orm:o,isVirtual:!1})})}),Object.entries(u.virtualFields).forEach(([e,n])=>{const r=n.as||e;a.hasOwnProperty(r)||Object.defineProperty(a,r,{get:()=>Ye({parent:a,model:t,fieldModel:u,field:n,accessorName:r,orm:o,isVirtual:!0})})}),a}const Ke={createDatabase:Ue},Ge=["indexes","meta"],Je=e=>Ge.includes(e);let We=function(){function e(e){const{createDatabase:t}={...Ke,...e||{}};this.createDatabase=t,this.registry=[],this.implicitThroughModels=[],this.installedFields={},this.stateSelector=e?e.stateSelector:null}var t=e.prototype;return t.register=function(...e){e.forEach(e=>{if(void 0===e.modelName)throw new Error("A model was passed that doesn't have a modelName set");e.invalidateClassCache(),this.registerManyToManyModelsFor(e),this.registry.push(e),Object.defineProperty(this,e.modelName,{get:()=>(this._setupModelPrototypes(this.registry),function({model:e,orm:t}){const n=new Xe({parent:null,orm:t,model:e});return Object.entries(e.fields).forEach(([r,s])=>{const o=s.as||r;Object.defineProperty(n,o,{get:()=>Ye({parent:n,model:e,fieldModel:e,field:s,accessorName:o,orm:t,isVirtual:!1})})}),Object.entries(e.virtualFields).forEach(([r,s])=>{const o=s.as||r;n.hasOwnProperty(o)||Object.defineProperty(n,o,{get:()=>Ye({parent:n,model:e,fieldModel:e,field:s,accessorName:o,orm:t,isVirtual:!0})})}),n}({model:e,orm:this}))})})},t.registerManyToManyModelsFor=function(e){const{fields:t}=e,n=e.modelName;Object.entries(t).forEach(([e,t])=>{if(!(t instanceof we))return;let r;r="this"===t.toModelName?n:t.toModelName;const o=n===r,i=J(n),a=W(r);if(t.through){if(o&&!t.throughFields)throw new Error("Self-referencing many-to-many relationship at "+`"${n}.${e}" using custom `+`model "${t.through}" has no `+"throughFields key. Cannot determine which fields reference the instances partaking in the relationship.")}else{const t=function(e){function t(){return e.apply(this,arguments)||this}return de()(t,e),t}(Ee);t.modelName=G(n,e);const c=function(e){function t(){return e.apply(this,arguments)||this}return de()(t,e),s()(t,[{key:"installsBackwardsVirtualField",get:function(){return!1}},{key:"installsBackwardsDescriptor",get:function(){return!1}}]),t}(be),u=o?c:be;t.fields={id:_e(),[i]:new u(n),[a]:new u(r)},t.invalidateClassCache(),this.implicitThroughModels.push(t)}})},t.get=function(e){const t=this.registry.concat(this.implicitThroughModels),n=Object.values(t).find(t=>t.modelName===e);if(void 0===n)throw new Error(`Did not find model ${e} from registry.`);return n},t.getModelClasses=function(){return this._setupModelPrototypes(this.registry),this._setupModelPrototypes(this.implicitThroughModels),this.registry.concat(this.implicitThroughModels)},t.generateSchemaSpec=function(){return{tables:this.getModelClasses().reduce((e,t)=>{const n=t.modelName,r=t.tableOptions();return Object.keys(r).filter(Je).forEach(e=>{throw new Error(`Reserved keyword \`${e}\` used in ${n}.options.`)}),e[n]={fields:{...t.fields},...r},e},{})}},t.getDatabase=function(){return this.db||(this.db=this.createDatabase(this.generateSchemaSpec())),this.db},t.getEmptyState=function(){return this.getDatabase().getEmptyState()},t.session=function(e){return new ue(this,this.getDatabase(),e)},t.mutableSession=function(e){return new ue(this,this.getDatabase(),e,!0)},t._setupModelPrototypes=function(e){e.filter(e=>!e.isSetUp).forEach(e=>{const{fields:t,modelName:n,querySetClass:r}=e;Object.entries(t).forEach(([t,r])=>{if(!(r instanceof fe))throw new Error(`${n}.${t} is of type "${typeof r}" `+"but must be an instance of Field. Please use the `attr`, `fk`, `oneToOne` and `many` functions to define fields.");this._isFieldInstalled(n,t)||(this._installField(r,t,e),this._setFieldInstalled(n,t))}),te(e,r),e.isSetUp=!0})},t._isFieldInstalled=function(e,t){return!!this.installedFields.hasOwnProperty(e)&&!!this.installedFields[e][t]},t._setFieldInstalled=function(e,t){this.installedFields.hasOwnProperty(e)||(this.installedFields[e]={}),this.installedFields[e][t]=!0},t._installField=function(e,t,n){new(0,e.installerClass)({field:e,fieldName:t,model:n,orm:this}).run()},t.withMutations=function(e){return K("`ORM.prototype.withMutations` has been deprecated. Use `ORM.prototype.mutableSession` instead."),this.mutableSession(e)},t.from=function(e){return K("`ORM.prototype.from` has been deprecated. Use `ORM.prototype.session` instead."),this.session(e)},t.getDefaultState=function(){return K("`ORM.prototype.getDefaultState` has been deprecated. Use `ORM.prototype.getEmptyState` instead."),this.getEmptyState()},t.define=function(){throw new Error("`ORM.prototype.define` has been removed. Please define a Model class.")},e}();var Ze=n(4),et=n(5),tt=n.n(et);const nt=(e,t)=>e===t,rt=e=>e&&"object"==typeof e&&e.hasOwnProperty("@@_______REDUX_ORM_STATE_FLAG"),st=(e,t,n)=>t.every((t,r)=>rt(t)&&rt(e[r])||n(t,e[r])),ot=(e,t,n)=>{const{accessedInstances:r}=e;return Object.entries(r).every(([r,s])=>{if(e.ormState[r]===t[r])return!0;const{mapName:o}=n.getDatabase().describe(r),{[o]:i}=e.ormState[r],{[o]:a}=t[r];return((e,t,n)=>e.every(e=>t[e]===n[e]))(Object.keys(s),i,a)})},it=(e,t)=>{const{accessedIndexes:n}=e;return Object.entries(n).every(([n,r])=>Object.entries(r).every(([r,s])=>s.every(s=>e.ormState[n].indexes[r][s]===t[n].indexes[r][s])))},at=(e,t)=>e.fullTableScannedModels.every(n=>e.ormState[n]===t[n]);function ct(e,t=nt,n){let r={result:null,args:null,ormState:null,fullTableScannedModels:[],accessedInstances:{},accessedIndexes:{}};return(...s)=>{const[o,...i]=s;if(Boolean(r.args)&&st(r.args,i,t)&&at(r,o)&&it(r,o)&&ot(r,o,n))return r.result;const a=n.session(o),c=i.map(e=>rt(e)?a:e),u=e.apply(null,c);return r={args:i,result:u,ormState:o,accessedInstances:a.accessedModelInstances,accessedIndexes:a.accessedIndexes,fullTableScannedModels:a.fullTableScannedModels},u}}function ut(e,t){e.sessionBoundModels.forEach(n=>{"function"==typeof n.reducer&&n.reducer(t,n,e)})}function lt(e,t=ut){return(n,r)=>{const s=e.session(n||e.getEmptyState());return t(s,r),s.state}}function dt(e){return e instanceof We?e:e instanceof qe&&e._orm}const ht=new Map,ft=Symbol.for("REDUX_ORM_SELECTOR");function pt(e){if("function"==typeof e)return e;if(e instanceof We)return e.stateSelector;if(e instanceof Qe&&(e._selector=pt(e._selector)),e instanceof qe){const{_orm:t,cachePath:n}=e;let r;ht.has(t)||ht.set(t,new Map),r=ht.get(t);for(let e=0;e<n.length;++e)r.has(n[e])||r.set(n[e],new Map),r=r.get(n[e]);if(r&&r.has(ft))return r.get(ft);const s=function e(t){if(t instanceof Qe){const n=e(t.parent);return t.createResultFunc(n)}return tt()(t.dependencies,t.resultFunc)({keySelector:t.keySelector,cacheObject:new et.FlatMapCache,selectorCreator:mt})}(e);return r.set(ft,s),s}throw new Error(`Failed to interpret selector argument: ${JSON.stringify(e)} of type ${typeof e}`)}function mt(...e){if(!e.length)throw new Error("Cannot create a selector without arguments.");const t=e.pop(),n=Array.isArray(e[0])?e[0]:e,r=n.map(dt).find(Boolean),s=n.map(pt);if("function"==typeof t){if(!r)throw new Error("Failed to resolve the current ORM database state. Please pass an ORM instance or an ORM selector as an argument to `createSelector()`.");if(!r.stateSelector)throw new Error("Failed to resolve the current ORM database state. Please pass an object to the ORM constructor that specifies a `stateSelector` function.");if("function"!=typeof r.stateSelector)throw new Error(`Failed to resolve the current ORM database state. Please pass a function when specifying the ORM's \`stateSelector\`. Received: ${JSON.stringify(r.stateSelector)} of type ${typeof r.stateSelector}`);return Object(Ze.createSelectorCreator)(ct,void 0,r)([r.stateSelector,...s],t)}if(t instanceof We)throw new Error("ORM instances cannot be the result function of selectors. You can access your models in the last function that you pass to `createSelector()`.");return s.length&&console.warn("Your input selectors will be ignored: the passed result function does not require any input."),pt(t)}n.d(t,"Schema",(function(){return yt})),n.d(t,"Backend",(function(){return gt})),n.d(t,"Attribute",(function(){return ye})),n.d(t,"QuerySet",(function(){return ce})),n.d(t,"Model",(function(){return Ee})),n.d(t,"ORM",(function(){return We})),n.d(t,"Session",(function(){return ue})),n.d(t,"ForeignKey",(function(){return be})),n.d(t,"ManyToMany",(function(){return we})),n.d(t,"OneToOne",(function(){return ve})),n.d(t,"fk",(function(){return Me})),n.d(t,"many",(function(){return Oe})),n.d(t,"attr",(function(){return _e})),n.d(t,"oneToOne",(function(){return Ne})),n.d(t,"createReducer",(function(){return lt})),n.d(t,"createSelector",(function(){return mt}));const yt=function(){throw new Error("Schema has been renamed to ORM. Please import ORM instead of Schema from Redux-ORM.")},gt=function(){throw new Error("Having a custom Backend instance is now unsupported. Documentation for database customization is upcoming, for now please look at the db folder in the source.")};t.default=Ee}])}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("ReduxOrm",[],t):"object"==typeof exports?exports.ReduxOrm=t():e.ReduxOrm=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=33)}([function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t,n){var r=n(14),o=n(15),s=n(16);e.exports=function(e){return r(e)||o(e)||s()}},function(e,t,n){"use strict";function r(e,t){return e===t}function o(e,t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var r=t.length,o=0;o<r;o++)if(!e(t[o],n[o]))return!1;return!0}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,n=null,s=null;return function(){return o(t,n,arguments)||(s=e.apply(null,arguments)),n=arguments,s}}function i(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every((function(e){return"function"==typeof e}))){var n=t.map((function(e){return typeof e})).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+n+"]")}return t}function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];var a=0,c=r.pop(),u=i(r),l=e.apply(void 0,[function(){return a++,c.apply(null,arguments)}].concat(n)),d=s((function(){for(var e=[],t=u.length,n=0;n<t;n++)e.push(u[n].apply(null,arguments));return l.apply(null,e)}));return d.resultFunc=c,d.recomputations=function(){return a},d.resetRecomputations=function(){return a=0},d}}t.__esModule=!0,t.defaultMemoize=s,t.createSelectorCreator=a,t.createStructuredSelector=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;if("object"!=typeof e)throw new Error("createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);var n=Object.keys(e);return t(n.map((function(t){return e[t]})),(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce((function(e,t,r){return e[n[r]]=t,e}),{})}))};var c=t.createSelector=a(s)},function(e,t,n){!function(e,t){"use strict";function n(e){return"string"==typeof e||"number"==typeof e}var r=function(){function e(){this._cache={}}var t=e.prototype;return t.set=function(e,t){this._cache[e]=t},t.get=function(e){return this._cache[e]},t.remove=function(e){delete this._cache[e]},t.clear=function(){this._cache={}},t.isValidCacheKey=function(e){return n(e)},e}(),o=r,s=function(){return!0};function i(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return function(e,r){if("function"==typeof r)throw new Error('[re-reselect] Second argument "options" must be an object. Please use "options.selectorCreator" to provide a custom selectorCreator.');var i={};"function"==typeof e?Object.assign(i,r,{keySelector:e}):Object.assign(i,e);var a=0,c=n.pop(),u=Array.isArray(n[0])?n[0]:[].concat(n);n.push((function(){return a++,c.apply(void 0,arguments)}));var l=i.cacheObject||new o,d=i.selectorCreator||t.createSelector,h=l.isValidCacheKey||s;i.keySelectorCreator&&(i.keySelector=i.keySelectorCreator({keySelector:i.keySelector,inputSelectors:u,resultFunc:c}));var f=function(){var e=i.keySelector.apply(i,arguments);if(h(e)){var t=l.get(e);return void 0===t&&(t=d.apply(void 0,n),l.set(e,t)),t.apply(void 0,arguments)}console.warn('[re-reselect] Invalid cache key "'+e+'" has been returned by keySelector function.')};return f.getMatchingSelector=function(){var e=i.keySelector.apply(i,arguments);return l.get(e)},f.removeMatchingSelector=function(){var e=i.keySelector.apply(i,arguments);l.remove(e)},f.clearCache=function(){l.clear()},f.resultFunc=c,f.dependencies=u,f.cache=l,f.recomputations=function(){return a},f.resetRecomputations=function(){return a=0},f.keySelector=i.keySelector,f}}function a(e){if(void 0===e)throw new Error('Missing the required property "cacheSize".');if(!Number.isInteger(e)||e<=0)throw new Error('The "cacheSize" property must be a positive integer value.')}var c=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache={},this._cacheOrdering=[],this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache[e]=t,this._cacheOrdering.push(e),this._cacheOrdering.length>this._cacheSize){var n=this._cacheOrdering[0];this.remove(n)}},t.get=function(e){return this._cache[e]},t.remove=function(e){var t=this._cacheOrdering.indexOf(e);t>-1&&this._cacheOrdering.splice(t,1),delete this._cache[e]},t.clear=function(){this._cache={},this._cacheOrdering=[]},t.isValidCacheKey=function(e){return n(e)},e}(),u=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache={},this._cacheOrdering=[],this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache[e]=t,this._registerCacheHit(e),this._cacheOrdering.length>this._cacheSize){var n=this._cacheOrdering[0];this.remove(n)}},t.get=function(e){return this._registerCacheHit(e),this._cache[e]},t.remove=function(e){this._deleteCacheHit(e),delete this._cache[e]},t.clear=function(){this._cache={},this._cacheOrdering=[]},t._registerCacheHit=function(e){this._deleteCacheHit(e),this._cacheOrdering.push(e)},t._deleteCacheHit=function(e){var t=this._cacheOrdering.indexOf(e);t>-1&&this._cacheOrdering.splice(t,1)},t.isValidCacheKey=function(e){return n(e)},e}(),l=function(){function e(){this._cache=new Map}var t=e.prototype;return t.set=function(e,t){this._cache.set(e,t)},t.get=function(e){return this._cache.get(e)},t.remove=function(e){this._cache.delete(e)},t.clear=function(){this._cache.clear()},e}(),d=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache=new Map,this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache.set(e,t),this._cache.size>this._cacheSize){var n=this._cache.keys().next().value;this.remove(n)}},t.get=function(e){return this._cache.get(e)},t.remove=function(e){this._cache.delete(e)},t.clear=function(){this._cache.clear()},e}(),h=function(){function e(e){var t=(void 0===e?{}:e).cacheSize;a(t),this._cache=new Map,this._cacheSize=t}var t=e.prototype;return t.set=function(e,t){if(this._cache.set(e,t),this._cache.size>this._cacheSize){var n=this._cache.keys().next().value;this.remove(n)}},t.get=function(e){var t=this._cache.get(e);return this._cache.has(e)&&(this.remove(e),this._cache.set(e,t)),t},t.remove=function(e){this._cache.delete(e)},t.clear=function(){this._cache.clear()},e}();e.FifoCacheObject=c,e.FifoMapCache=d,e.FifoObjectCache=c,e.FlatCacheObject=r,e.FlatMapCache=l,e.FlatObjectCache=r,e.LruCacheObject=h,e.LruMapCache=h,e.LruObjectCache=u,e.createStructuredCachedSelector=function(e){return t.createStructuredSelector(e,i)},e.default=i,Object.defineProperty(e,"__esModule",{value:!0})}(t,n(4))},function(e,t,n){var r=n(17),o=n(7),s=n(18),i=n(19),a=n(20),c=n(21),u=n(8);e.exports=function(e,t,n){var l=-1;t=r(t.length?t:[u],a(o));var d=s(e,(function(e,n,o){return{criteria:r(t,(function(t){return t(e)})),index:++l,value:e}}));return i(d,(function(e,t){return c(e,t,n)}))}},function(e,t){e.exports=function(e){return e}},function(e,t){e.exports=function(e){return e}},function(e,t){var n=Array.isArray;e.exports=n},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,s=[];++n<r;){var i=e[n];t(i,n,e)&&(s[o++]=i)}return s}},function(e,t,n){var r=n(6),o=n(9);e.exports=function(e,t,n,s){return null==e?[]:(o(t)||(t=null==t?[]:[t]),o(n=s?void 0:n)||(n=null==n?[]:[n]),r(e,t,n))}},function(e,t,n){var r=n(24),o=n(25),s=n(7),i=n(9),a=n(26);e.exports=function(e,t){return(i(e)?r:o)(e,a(s(t,3)))}},function(e,t,n){var r=n(27),o=n(6),s=n(28),i=n(32),a=s((function(e,t){if(null==e)return[];var n=t.length;return n>1&&i(e,t[0],t[1])?t=[]:n>2&&i(t[0],t[1],t[2])&&(t=[t[0]]),o(e,r(t,1),[])}));e.exports=a},function(e,t){e.exports=function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}},function(e,t){e.exports=function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=Array(r);++n<r;)o[n]=t(e[n],n,e);return o}},function(e,t){e.exports=function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}},function(e,t){e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){var r=n(22);e.exports=function(e,t,n){for(var o=-1,s=e.criteria,i=t.criteria,a=s.length,c=n.length;++o<a;){var u=r(s[o],i[o]);if(u)return o>=c?u:u*("desc"==n[o]?-1:1)}return e.index-t.index}},function(e,t,n){var r=n(23);e.exports=function(e,t){if(e!==t){var n=void 0!==e,o=null===e,s=e==e,i=r(e),a=void 0!==t,c=null===t,u=t==t,l=r(t);if(!c&&!l&&!i&&e>t||i&&a&&u&&!c&&!l||o&&a&&u||!n&&u||!s)return 1;if(!o&&!i&&!l&&e<t||l&&n&&s&&!o&&!i||c&&n&&s||!a&&s||!u)return-1}return 0}},function(e,t){e.exports=function(){return!1}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,s=[];++n<r;){var i=e[n];t(i,n,e)&&(s[o++]=i)}return s}},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,o=0,s=[];++n<r;){var i=e[n];t(i,n,e)&&(s[o++]=i)}return s}},function(e,t){var n="Expected a function";e.exports=function(e){if("function"!=typeof e)throw new TypeError(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}},function(e,t){e.exports=function(e){return e&&e.length?e[0]:void 0}},function(e,t,n){var r=n(8),o=n(29),s=n(31);e.exports=function(e,t){return s(o(e,t,r),e+"")}},function(e,t,n){var r=n(30),o=Math.max;e.exports=function(e,t,n){return t=o(void 0===t?e.length-1:t,0),function(){for(var s=arguments,i=-1,a=o(s.length-t,0),c=Array(a);++i<a;)c[i]=s[t+i];i=-1;for(var u=Array(t+1);++i<t;)u[i]=s[i];return u[t]=n(c),r(e,this,u)}}},function(e,t){e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t){e.exports=function(e){return e}},function(e,t){e.exports=function(){return!1}},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),s=n(3),i=n.n(s),a=n(2),c=n.n(a);function u(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function l(e){return function t(n){return 0===arguments.length||u(n)?t:e.apply(this,arguments)}}function d(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(e){return t.apply(this,arguments)};case 2:return function(e,n){return t.apply(this,arguments)};case 3:return function(e,n,r){return t.apply(this,arguments)};case 4:return function(e,n,r,o){return t.apply(this,arguments)};case 5:return function(e,n,r,o,s){return t.apply(this,arguments)};case 6:return function(e,n,r,o,s,i){return t.apply(this,arguments)};case 7:return function(e,n,r,o,s,i,a){return t.apply(this,arguments)};case 8:return function(e,n,r,o,s,i,a,c){return t.apply(this,arguments)};case 9:return function(e,n,r,o,s,i,a,c,u){return t.apply(this,arguments)};case 10:return function(e,n,r,o,s,i,a,c,u,l){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function h(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return u(n)?t:l((function(t){return e(n,t)}));default:return u(n)&&u(r)?t:u(n)?l((function(t){return e(t,r)})):u(r)?l((function(t){return e(n,t)})):e(n,r)}}}var f=h((function(e,t){return 1===e?l(t):d(e,function e(t,n,r){return function(){for(var o=[],s=0,i=t,a=0;a<n.length||s<arguments.length;){var c;a<n.length&&(!u(n[a])||s>=arguments.length)?c=n[a]:(c=arguments[s],s+=1),o[a]=c,u(c)||(i-=1),a+=1}return i<=0?r.apply(this,o):d(i,e(t,o,r))}}(e,[],t))})),p=l((function(e){return f(e.length,e)})),m={"@@functional/placeholder":!0};function y(e,t){for(var n in e)e.hasOwnProperty(n)&&t(e[n],n)}var g="@@_______immutableOpsOwnerID";function b(e,t){return!!t&&e[g]===t}var w="function"==typeof Symbol?function(){return Symbol("ownerID")}:function(){return{}};function v(e,t){return t&&function(e,t){Object.defineProperty(e,g,{value:t,configurable:!0,enumerable:!1})}(e,t),e}function _(e){return e instanceof Array?e:[e]}var M=".";function O(e){return"string"==typeof e?-1===e.indexOf(M)?[e]:e.split(M):e}function N(e,t,n){return n[e]=t,n}function S(e,t,n){var r=_(t);return e?r.forEach((function(t){y(t,(function(t,r){var o;e&&n.hasOwnProperty(r)?(o="object"===c()(t)?S(e,[t],n[r]):t,n[r]=o):n[r]=t}))})):Object.assign.apply(Object,[n].concat(i()(r))),n}var k=S.bind(null,!1),E=S.bind(null,!0);function j(e,t){return _(e).forEach((function(e){delete t[e]})),t}function x(e,t,n){return e[n]!==t[n]}function F(e,t,n,r){if(b(r,t))return S(e,n,r);var o=_(n),s=!1,i=r,a=function(){s||(s=!0,v(i=Object.assign({},r),t))};return o.forEach((function(n){y(n,(function(o,s){if(e&&r.hasOwnProperty(s)){var u=i[s];if("object"===c()(o)&&!(o instanceof Array)){if(x(i,n,s)){var l=F(e,t,o,u);l!==u&&(a(),i[s]=l)}return!0}}x(i,n,s)&&(a(),i[s]=o)}))})),i}var C=F.bind(null,!0);function A(e,t,n,r){if(b(r,e))return N(t,n,r);if(r[t]===n)return r;var o=function(e){for(var t=new Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}(r);return o[t]=n,v(o,e),o}function I(e,t){for(var n=0,r=0;n<t.length;){e(t[n],r)?n++:t.splice(n,1),r++}return t}function R(e,t,n,r){var o=_(n);return r.splice.apply(r,[e,t].concat(i()(o))),r}function D(e,t,n){return R(e,0,t,n)}function $(e,t,n,r,o){if(b(o,e))return R(t,n,r,o);var s=_(r),a=o.slice();return v(a,e),a.splice.apply(a,[t,n].concat(i()(s))),a}function T(e,t,n,r){return b(r,e)?D(t,n,r):$(e,t,0,n,r)}var P={merge:F.bind(null,!1),deepMerge:C,omit:function(e,t,n){if(b(n,e))return j(t,n);var r=_(t).filter((function(e){return n.hasOwnProperty(e)}));if(0===r.length)return n;var o=Object.assign({},n);return r.forEach((function(e){delete o[e]})),v(o,e),o},setIn:function(e,t,n,r){var o=O(t),s=function(e,t){for(var n=O(e),r=t,o=0;o<n.length;o++){var s=r[n[o]];if(o===n.length-1)return s;if("object"!==c()(s))return;r=s}}(o,r);if(n===s)return r;var i,a=o.length,u=i=b(r,e)?r:Object.assign(v({},e),r);return o.forEach((function(t,r){if(r!==a-1){var s=i[t],u=c()(s);if("object"!==u){if("undefined"===u){var l=v({},e);return i[t]=l,void(i=l)}var d="".concat(o[r-1],".").concat(t);throw new Error("A non-object value was encountered when traversing setIn path at ".concat(d,"."))}if(b(s,e))i=s;else{var h=v({},e);i[t]=Object.assign(h,s),i=h}}else i[t]=n})),u},insert:T,push:function(e,t,n){return T(e,n.length,t,n)},filter:function(e,t,n){if(b(n,e))return I(t,n);var r=n.filter(t);return r.length===n.length?n:(v(r,e),r)},splice:$,set:function(e,t,n,r){if(function(e){return e&&"object"===c()(e)&&"number"==typeof e.length&&e.length>=0&&e.length%1==0}(r))return A(e,t,n,r);if(b(r,e))return N(t,n,r);if(r[t]===n)return r;var o=Object.assign({},r);return v(o,e),o[t]=n,o}},B={merge:k,deepMerge:E,omit:j,setIn:function(e,t,n){for(var r=O(e),o=r.length,s=!1,i=0,a=n,u=r[i];!s;)if(i===o-1)a[u]=t,s=!0;else{var l=c()(a[u]);if("undefined"===l){var d={};v(d,null),a[u]=d}else if("object"!==l){var h="".concat(r[i-1],".").concat(u);throw new Error("A non-object value was encountered when traversing setIn path at ".concat(h,"."))}a=a[u],u=r[++i]}return n},insert:D,push:function(e,t){var n=_(e);return t.push.apply(t,i()(n)),t},filter:I,splice:R,set:N};var V=function(){var e=Object.assign({},P);y(e,(function(t,n){e[n]=p(t.bind(null,null))}));var t=Object.assign({},B);y(t,(function(e,n){t[n]=p(e)}));var n=Object.assign({},P);return y(n,(function(e,t){n[t]=p(e)})),Object.assign(e,{mutable:t,batch:n,batched:function(e,t){var n,r;"function"==typeof e?(r=e,n=w()):(n=e,r=t);var o=Object.assign({},P);return y(o,(function(e,t){o[t]=p(e.bind(null,n))})),r(o)},__:m,getBatchToken:w})}();const U="REDUX_ORM_UPDATE",q="REDUX_ORM_DELETE",z="REDUX_ORM_CREATE",L="REDUX_ORM_FILTER",Q="REDUX_ORM_EXCLUDE",X="SUCCESS",H=Symbol("REDUX_ORM_ALL_INSTANCES"),Y=(e,t)=>void 0===t?H:t;function K(e){return("function"==typeof console.warn?console.warn.bind(console):console.log.bind(console))(e)}function G(e,t){return e+((n=t).charAt(0).toUpperCase()+n.slice(1));var n}function J(e){return`from${e}Id`}function W(e){return`to${e}Id`}function Z(e){return function(...t){return this.getQuerySet()[e](...t)}}function ee(e){return function(){return this.getQuerySet()[e]}}function te(e,t){const n=t.sharedMethods.slice();!function(e,t){let n=e;for(;n!==Function.prototype;)t(n),n=Object.getPrototypeOf(n)}(t,t=>{for(let r=0;r<n.length;r++){let o=!1;const s=n[r],i=Object.getOwnPropertyDescriptor(t.prototype,s);void 0!==i&&(void 0!==i.get?(i.get=ee(s),Object.defineProperty(e,s,i)):e[s]=Z(s),o=!0),o&&n.splice(r--,1)}})}function ne(e){return null!=e&&"function"==typeof e.getId?e.getId():e}const{getBatchToken:re}=V;function oe({type:e,payload:t},n){if(e!==L)return!1;if("object"!=typeof t)return!1;if(!t.hasOwnProperty(n))return!1;const r=t[n];return null!==r&&void 0!==r}function se(e,t){return Object.entries(e).reduce((e,[n,r])=>(e[n]=t(r),e),{})}function ie(e){return e&&"string"!=typeof e?e.modelName:e}const ae=function(){function e(e,t,n){Object.assign(this,{modelClass:e,clauses:t||[]}),this._opts=n}e.addSharedMethod=function(e){this.sharedMethods=this.sharedMethods.concat(e)};var t=e.prototype;return t._new=function(e,t){const n={...this._opts,...t};return new this.constructor(this.modelClass,e,n)},t.toString=function(){return this._evaluate(),`QuerySet contents:\n - ${this.rows.map(({id:e})=>this.modelClass.withId(e).toString()).join("\n - ")}`},t.toRefArray=function(){return this._evaluate()},t.toModelArray=function(){const{modelClass:e}=this;return this._evaluate().map(t=>new e(t))},t.count=function(){return this._evaluate(),this.rows.length},t.exists=function(){return Boolean(this.count())},t.at=function(e){const{modelClass:t}=this,n=this._evaluate();if(e>=0&&e<n.length)return new t(n[e])},t.first=function(){return this.at(0)},t.last=function(){const e=this._evaluate();return this.at(e.length-1)},t.all=function(){return this._new(this.clauses)},t.filter=function(e){const t="object"==typeof e?se(e,ne):e,n={type:L,payload:t};return this._new(this.clauses.concat(n))},t.exclude=function(e){const t="object"==typeof e?se(e,ne):e,n={type:Q,payload:t};return this._new(this.clauses.concat(n))},t._evaluate=function(){if(void 0===this.modelClass.session)throw new Error([`Tried to query the ${this.modelClass.modelName} model's table without a session. `,"Create a session using `session = orm.session()` and use ",`\`session["${this.modelClass.modelName}"]\` for querying instead.`].join(""));if(!this._evaluated){const{session:e,modelName:t}=this.modelClass,n={table:t,clauses:this.clauses};this.rows=e.query(n).rows,this._evaluated=!0}return this.rows},t.orderBy=function(e,t){const n={type:"REDUX_ORM_ORDER_BY",payload:[e,t]};return this._new(this.clauses.concat(n))},t.update=function(e){const{session:t,modelName:n}=this.modelClass;t.applyUpdate({action:U,query:{table:n,clauses:this.clauses},payload:e}),this._evaluated=!1},t.delete=function(){const{session:e,modelName:t}=this.modelClass;this.toModelArray().forEach(e=>e._onDelete()),e.applyUpdate({action:q,query:{table:t,clauses:this.clauses}}),this._evaluated=!1},t.map=function(){throw new Error("`QuerySet.prototype.map` has been removed. Call `.toModelArray()` or `.toRefArray()` first to map.")},t.forEach=function(){throw new Error("`QuerySet.prototype.forEach` has been removed. Call `.toModelArray()` or `.toRefArray()` first to iterate.")},o()(e,[{key:"withModels",get:function(){throw new Error("`QuerySet.prototype.withModels` has been removed. Use `.toModelArray()` or predicate functions that instantiate Models from refs, e.g. `new Model(ref)`.")}},{key:"withRefs",get:function(){K("`QuerySet.prototype.withRefs` has been deprecated. Query building operates on refs only now.")}}]),e}();ae.sharedMethods=["count","at","all","last","first","filter","exclude","orderBy","update","delete"];var ce=ae;var ue=function(){function e(e,t,n,r,o){this.schema=e,this.db=t,this.state=n||t.getEmptyState(),this.initialState=this.state,this.withMutations=Boolean(r),this.batchToken=o||w(),this.modelData={},this.models=e.getModelClasses(),this.sessionBoundModels=this.models.map(e=>{function t(){return Reflect.construct(e,arguments,t)}return Reflect.setPrototypeOf(t.prototype,e.prototype),Reflect.setPrototypeOf(t,e),Object.defineProperty(this,e.modelName,{get:()=>t}),t.connect(this),t})}var t=e.prototype;return t.getDataForModel=function(e){return this.modelData[e]||(this.modelData[e]={}),this.modelData[e]},t.getModelData=function(){return this.modelData},t.markAccessed=function(e,t){const n=this.getDataForModel(e);n.accessedInstances||(n.accessedInstances={}),t.forEach(e=>{n.accessedInstances[e]=!0})},t.markFullTableScanned=function(e){this.getDataForModel(e).fullTableScanned=!0},t.markAccessedIndexes=function(e){e.forEach(([e,t,n])=>{const r=this.getDataForModel(e);r.accessedIndexes||(r.accessedIndexes={}),r.accessedIndexes[t]=[...r.accessedIndexes[t]||[],n]})},t.applyUpdate=function(e){const t=this._getTransaction(e),n=this.db.update(e,t,this.state),{status:r,state:o,payload:s}=n;if(r!==X)throw new Error(`Applying update failed with status ${r}. Payload: ${s}`);return this.state=o,s},t.query=function(e){const t=this.db.query(e,this.state);return this._markAccessedByQuery(e,t),t},t._getTransaction=function(e){const{withMutations:t}=this,{action:n}=e;let{batchToken:r}=this;return[U,q].includes(n)&&(r=w()),{batchToken:r,withMutations:t}},t._markAccessedByQuery=function(e,t){const{table:n,clauses:r}=e,{rows:o}=t,{idAttribute:s}=this[n],i=new Set(o.map(e=>e[s])),a=r.some(e=>!!oe(e,s)&&(i.add(e.payload[s]),!0)),c=[],{indexes:u}=this.state[n];r.forEach(e=>{Object.keys(u).forEach(t=>{if(!oe(e,t))return;const r=e.payload[t];c.push([n,t,r])})}),a?this.markAccessed(n,i):c.length?(this.markAccessed(n,i),this.markAccessedIndexes(c)):this.markFullTableScanned(n)},t.getNextState=function(){return K("`Session.prototype.getNextState` has been deprecated. Access the `Session.prototype.state` property instead."),this.state},t.reduce=function(){throw new Error("`Session.prototype.reduce` has been removed. The Redux integration API is now decoupled from ORM and Session - see the 0.9 migration guide in the GitHub repo.")},o()(e,[{key:"accessedModelInstances",get:function(){return Object.entries(this.getModelData()).reduce((e,[t,n])=>(n.accessedInstances&&(e[t]=n.accessedInstances),e),{})}},{key:"fullTableScannedModels",get:function(){return Object.entries(this.getModelData()).reduce((e,[t,n])=>(n.fullTableScanned&&e.push(t),e),[])}},{key:"accessedIndexes",get:function(){return Object.entries(this.getModelData()).reduce((e,[t,n])=>(n.accessedIndexes&&(e[t]=n.accessedIndexes),e),{})}}]),e}(),le=n(1),de=n.n(le);var he=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.installForwardsDescriptor=function(){Object.defineProperty(this.model.prototype,this.fieldName,this.field.createForwardsDescriptor(this.fieldName,this.model,this.toModel,this.throughModel))},n.installForwardsVirtualField=function(){this.model.virtualFields[this.fieldName]=this.field.createForwardsVirtualField(this.fieldName,this.model,this.toModel,this.throughModel)},n.installBackwardsDescriptor=function(){if(Object.getOwnPropertyDescriptor(this.toModel.prototype,this.backwardsFieldName))throw new Error((e=this.model.modelName,t=this.fieldName,n=this.toModel.modelName,[`Reverse field ${this.backwardsFieldName} already defined`,` on model ${n}. To fix, set a custom related`,` name on ${e}.${t}.`].join("")));var e,t,n;Object.defineProperty(this.toModel.prototype,this.backwardsFieldName,this.field.createBackwardsDescriptor(this.fieldName,this.model,this.toModel,this.throughModel))},n.installBackwardsVirtualField=function(){this.toModel.virtualFields[this.backwardsFieldName]=this.field.createBackwardsVirtualField(this.fieldName,this.model,this.toModel,this.throughModel)},t}(function(){function e(e){this.field=e.field,this.fieldName=e.fieldName,this.model=e.model,this.orm=e.orm,this.field.references(this.model)&&(this.field.toModelName="this")}return e.prototype.run=function(){this.installForwardsDescriptor(),this.field.installsForwardsVirtualField&&this.installForwardsVirtualField(),this.field.installsBackwardsDescriptor&&this.installBackwardsDescriptor(),this.field.installsBackwardsVirtualField&&this.installBackwardsVirtualField()},o()(e,[{key:"toModel",get:function(){if(void 0===this._toModel){const{toModelName:e}=this.field;this._toModel=e?"this"===e?this.model:this.orm.get(e):null}return this._toModel}},{key:"throughModel",get:function(){if(void 0===this._throughModel){const e=this.field.getThroughModelName(this.fieldName,this.model);this._throughModel=e?this.orm.get(e):null}return this._throughModel}},{key:"backwardsFieldName",get:function(){return this.field.getBackwardsFieldName(this.model)}}]),e}());var fe=function(){function e(){}var t=e.prototype;return t.getClass=function(){return this.constructor},t.references=function(e){return!1},t.getThroughModelName=function(e,t){return null},o()(e,[{key:"installerClass",get:function(){return he}},{key:"installsForwardsVirtualField",get:function(){return!1}},{key:"installsBackwardsDescriptor",get:function(){return!1}},{key:"installsBackwardsVirtualField",get:function(){return!1}},{key:"index",get:function(){return!1}}]),e}();function pe(e,t){return{get(){const{session:{[t]:n}}=this.getClass(),{[e]:r}=this._fields;return n.withId(r)},set(t){this.update({[e]:ne(t)})}}}function me(e,t,n,r,o){return{get(){const{session:{[e]:s,[t]:i,[n]:a}}=this.getClass(),c=o?i:s,u=o?s:i,l=o?r.to:r.from,d=o?r.from:r.to,h=this.getId(),f=a.filter({[l]:h}),p=new Set(f.toRefArray().map(e=>e[d])),m=u.filter(e=>p.has(e[u.idAttribute]));return m.add=function(...e){const t=new Set(e.map(ne)),n=f.filter(e=>t.has(e[d]));if(n.exists()){const e=n.toRefArray().map(e=>e[d]);throw new Error(`Tried to add already existing ${u.modelName} id(s) ${e} to the ${c.modelName} instance with id ${h}`)}t.forEach(e=>{a.create({[d]:e,[l]:h})})},m.clear=function(){f.delete()},m.remove=function(...e){const t=new Set(e.map(ne)),n=f.filter(e=>t.has(e[d]));if(n.count()!==t.size){const e=n.toRefArray().map(e=>e[d]),r=[...t].filter(t=>!e.includes(t));throw new Error(`Tried to delete non-existing ${u.modelName} id(s) ${r} from the ${c.modelName} instance with id ${h}`)}n.delete()},m},set(){throw new Error("Tried setting a M2M field. Please use the related QuerySet methods add, remove and clear.")}}}var ye=function(e){function t(t){var n;return(n=e.call(this)||this).opts=t||{},n.opts.hasOwnProperty("getDefault")&&(n.getDefault=n.opts.getDefault),n}return de()(t,e),t.prototype.createForwardsDescriptor=function(e,t){return function(e){return{get(){return this._fields[e]},set(t){return this.set(e,t)},enumerable:!0,configurable:!0}}(e)},t}(fe);var ge=function(e){function t(...t){var n;if(n=e.call(this)||this,1===t.length&&"object"==typeof t[0]){const e=t[0];n.toModelName=ie(e.to),n.relatedName=e.relatedName,n.through=ie(e.through),n.throughFields=e.throughFields,n.as=e.as}else[n.toModelName,n.relatedName]=[ie(t[0]),t[1]];return n}de()(t,e);var n=t.prototype;return n.getBackwardsFieldName=function(e){return this.relatedName||e.modelName.toLowerCase()+"Set"},n.createBackwardsVirtualField=function(e,t,n,r){return new(this.getClass())(t.modelName,e)},n.references=function(e){return this.toModelName===e.modelName},o()(t,[{key:"installsBackwardsVirtualField",get:function(){return!0}},{key:"installsBackwardsDescriptor",get:function(){return!0}},{key:"installerClass",get:function(){return function(e){function t(){return e.apply(this,arguments)||this}return de()(t,e),t.prototype.installForwardsDescriptor=function(){Object.defineProperty(this.model.prototype,this.field.as||this.fieldName,this.field.createForwardsDescriptor(this.fieldName,this.model,this.toModel,this.throughModel))},t}(he)}}]),t}(fe);var be=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.createForwardsDescriptor=function(e,t,n,r){return pe(e,n.modelName)},n.createBackwardsDescriptor=function(e,t,n,r){return o=e,s=t.modelName,{get(){const{session:{[s]:e}}=this.getClass();return e.filter({[o]:this.getId()})},set(){throw new Error("Can't mutate a reverse many-to-one relation.")}};var o,s},o()(t,[{key:"index",get:function(){return!0}}]),t}(ge);var we=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.getDefault=function(){return[]},n.getThroughModelName=function(e,t){return this.through||G(t.modelName,e)},n.createForwardsDescriptor=function(e,t,n,r){return me(t.modelName,n.modelName,r.modelName,this.getThroughFields(e,t,n,r),!1)},n.createBackwardsDescriptor=function(e,t,n,r){return me(t.modelName,n.modelName,r.modelName,this.getThroughFields(e,t,n,r),!0)},n.createBackwardsVirtualField=function(e,t,n,r){return new(this.getClass())({to:t.modelName,relatedName:e,through:r.modelName,throughFields:this.getThroughFields(e,t,n,r)})},n.createForwardsVirtualField=function(e,t,n,r){return new(this.getClass())({to:n.modelName,relatedName:e,through:this.through,throughFields:this.getThroughFields(e,t,n,r),as:this.as})},n.getThroughFields=function(e,t,n,r){if(this.throughFields){const[e,t]=this.throughFields,o=r.fields[e];return{to:o.references(n)?e:t,from:o.references(n)?t:e}}if(t.modelName===n.modelName)return{to:W(n.modelName),from:J(t.modelName)};const o=e=>Object.keys(r.fields).find(t=>r.fields[t].references(e));return{to:o(n),from:o(t)}},o()(t,[{key:"installsForwardsVirtualField",get:function(){return!0}}]),t}(ge);var ve=function(e){function t(){return e.apply(this,arguments)||this}de()(t,e);var n=t.prototype;return n.getBackwardsFieldName=function(e){return this.relatedName||e.modelName.toLowerCase()},n.createForwardsDescriptor=function(e,t,n,r){return function(...e){return pe(...e)}(e,n.modelName)},n.createBackwardsDescriptor=function(e,t,n,r){return o=e,s=t.modelName,{get(){const{session:{[s]:e}}=this.getClass();return e.get({[o]:this.getId()})},set(){throw new Error("Can't mutate a reverse one-to-one relation.")}};var o,s},t}(ge);function _e(e){return new ye(e)}function Me(...e){return new be(...e)}function Oe(...e){return new we(...e)}function Ne(...e){return new ve(...e)}function Se(e){const t=e.getClass(),{idAttribute:n,modelName:r}=t;return{table:r,clauses:[{type:L,payload:{[n]:e.getId()}}]}}const ke=function(){function e(e){this._initFields(e)}var t=e.prototype;return t._initFields=function(e){const t=Object(e);this._fields={...t},Object.keys(t).forEach(e=>{e in this||Object.defineProperty(this,e,{get:()=>this._fields[e],set:t=>this.set(e,t),configurable:!0,enumerable:!0})})},e.toString=function(){return`ModelClass: ${this.modelName}`},e.options=function(){return{}},e.markAccessed=function(e){if(void 0===this._session)throw new Error([`Tried to mark rows of the ${this.modelName} model as accessed without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].markAccessed\` instead.`].join(""));this.session.markAccessed(this.modelName,e)},e.markFullTableScanned=function(){if(void 0===this._session)throw new Error([`Tried to mark the ${this.modelName} model as full table scanned without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].markFullTableScanned\` instead.`].join(""));this.session.markFullTableScanned(this.modelName)},e.markAccessedIndexes=function(e){if(void 0===this._session)throw new Error([`Tried to mark indexes for the ${this.modelName} model as accessed without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].markAccessedIndexes\` instead.`].join(""));this.session.markAccessedIndexes(e.map(([e,t])=>[this.modelName,e,t]))},e.connect=function(e){if(!(e instanceof ue))throw new Error("A model can only be connected to instances of Session.");this._session=e},e.getQuerySet=function(){const{querySetClass:e}=this;return new e(this)},e.invalidateClassCache=function(){this.isSetUp=void 0,this.virtualFields={}},e.tableOptions=function(){return"function"==typeof this.backend?(K("`Model.backend` has been deprecated. Please rename to `.options`."),this.backend()):this.backend?(K("`Model.backend` has been deprecated. Please rename to `.options`."),this.backend):"function"==typeof this.options?this.options():this.options},e.create=function(e){if(void 0===this._session)throw new Error([`Tried to create a ${this.modelName} model instance without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].create\` instead.`].join(""));const t={...e},n={},r=Object.keys(this.fields),o=Object.keys(this.virtualFields);r.forEach(r=>{const o=this.fields[r],s=e.hasOwnProperty(r);if(o instanceof we)s&&(n[r]=e[r],o.as||delete t[r]);else if(s){const n=e[r];t[r]=ne(n)}else o.getDefault&&(t[r]=o.getDefault())}),o.forEach(r=>{if(!n.hasOwnProperty(r)){const o=this.virtualFields[r];e.hasOwnProperty(r)&&o instanceof we&&(n[r]=e[r],delete t[r])}});const s=new this(this.session.applyUpdate({action:z,table:this.modelName,payload:t}));return s._refreshMany2Many(n),s},e.upsert=function(e){if(void 0===this.session)throw new Error([`Tried to upsert a ${this.modelName} model instance without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].upsert\` instead.`].join(""));const{idAttribute:t}=this;if(e.hasOwnProperty(t)){const n=e[t];if(this.idExists(n)){const t=this.withId(n);return t.update(e),t}}return this.create(e)},e.withId=function(e){return this.get({[this.idAttribute]:e})},e.idExists=function(e){return this.exists({[this.idAttribute]:e})},e.exists=function(e){if(void 0===this.session)throw new Error([`Tried to check if a ${this.modelName} model instance exists without a session. `,"Create a session using `session = orm.session()` and call ",`\`session["${this.modelName}"].exists\` instead.`].join(""));return Boolean(this._findDatabaseRows(e).length)},e.get=function(e){const t=this._findDatabaseRows(e);if(0===t.length)return null;if(t.length>1)throw new Error(`Expected to find a single row in \`${this.modelName}.get\`. Found ${t.length}.`);return new this(t[0])},t.getClass=function(){return this.constructor},t.getId=function(){return this._fields[this.getClass().idAttribute]},e._findDatabaseRows=function(e){const t={table:this.modelName};return e&&(t.clauses=[{type:L,payload:e}]),this.session.query(t).rows},t.toString=function(){const e=this.getClass();return`${e.modelName}: {${Object.keys(e.fields).map(t=>{if(e.fields[t]instanceof we){return`${t}: [${this[t].toModelArray().map(e=>e.getId()).join(", ")}]`}return`${t}: ${this._fields[t]}`}).join(", ")}}`},t.equals=function(e){return function(e,t){const n=Object.entries(Object(e));return n.length===Object.keys(t).length&&n.every(([e,n])=>t.hasOwnProperty(e)&&t[e]===n)}(this._fields,e._fields)},t.set=function(e,t){this.update({[e]:t})},t.update=function(e){const t=this.getClass();if(void 0===t.session)throw new Error([`Tried to update a ${t.modelName} model instance without a session. `,"You cannot call `.update` on an instance that you did not receive from the database."].join(""));const n={...e},{fields:r,virtualFields:o}=t,s={};for(const e in n){if(r.hasOwnProperty(e)){const t=r[e];t instanceof be||t instanceof ve?n[e]=ne(n[e]):t instanceof we&&(s[e]=n[e],t.as||delete n[e])}else if(o.hasOwnProperty(e)){o[e]instanceof we&&(s[e]=n[e],delete n[e])}}const i={...this._fields,...n},a=new t(i);this.equals(a)||(this._initFields(i),t.session.applyUpdate({action:U,query:Se(this),payload:n})),this._refreshMany2Many(s)},t.refreshFromState=function(){this._initFields(this.ref)},t.delete=function(){const e=this.getClass();if(void 0===e.session)throw new Error([`Tried to delete a ${e.modelName} model instance without a session. `,"You cannot call `.delete` on an instance that you did not receive from the database."].join(""));this._onDelete(),e.session.applyUpdate({action:q,query:Se(this)})},t._refreshMany2Many=function(e){const t=this.getClass(),{fields:n,virtualFields:r,modelName:o}=t;Object.keys(e).forEach(s=>{const i=!n.hasOwnProperty(s),a=r[s],c=e[s];if(!Array.isArray(c))throw new TypeError(`Failed to resolve many-to-many relationship: ${o}[${s}] must be an array (passed: ${c})`);const u=c.map(ne),l=[...new Set(u)];if(u.length!==l.length)throw new Error(`Found duplicate id(s) when passing "${u}" to ${t.modelName}.${s} value`);const d=a.through||G(t.modelName,s),h=t.session[d];let f,p;i?({from:p,to:f}=a.throughFields):({from:f,to:p}=a.throughFields);const m=function(e,t){const n=e.filter(e=>t.includes(e)),r=e.filter(e=>!n.includes(e)),o=t.filter(e=>!n.includes(e));return r.length||o.length?{delete:r,add:o}:null}(h.filter(e=>e[f]===this[t.idAttribute]).toRefArray().map(e=>e[p]),u);if(m){const{delete:e,add:t}=m;e.length>0&&this[a.as||s].remove(...e),t.length>0&&this[a.as||s].add(...t)}})},t._onDelete=function(){const{virtualFields:e}=this.getClass();for(const t in e){const n=e[t];if(n instanceof we)this[t].clear();else if(n instanceof be){const e=this[t];e.exists()&&e.update({[n.relatedName]:null})}else n instanceof ve&&null!==this[t]&&(this[t][n.relatedName]=null)}},e.hasId=function(e){return console.warn("`Model.hasId` has been deprecated. Please use `Model.idExists` instead."),this.idExists(e)},t.getNextState=function(){throw new Error("`Model.prototype.getNextState` has been removed. See the 0.9 migration guide on the GitHub repo.")},o()(e,[{key:"ref",get:function(){const e=this.getClass();return e._findDatabaseRows({[e.idAttribute]:this.getId()})[0]}}],[{key:"idAttribute",get:function(){if(void 0===this._session)throw new Error([`Tried to get the ${this.modelName} model's id attribute without a session. `,"Create a session using `session = orm.session()` and access ",`\`session["${this.modelName}"].idAttribute\` instead.`].join(""));return this.session.db.describe(this.modelName).idAttribute}},{key:"session",get:function(){return this._session}},{key:"query",get:function(){return this.getQuerySet()}}]),e}();ke.fields={id:_e()},ke.virtualFields={},ke.querySetClass=ce;var Ee=ke,je=n(10),xe=n.n(je),Fe=n(11),Ce=n.n(Fe),Ae=n(12),Ie=n.n(Ae),Re=n(13),De=n.n(Re);const $e={idAttribute:"id",arrName:"items",mapName:"itemsById",fields:{}};var Te=function(){function e(e){Object.assign(this,$e,e)}var t=e.prototype;return t.accessId=function(e,t){return e[this.mapName][t]},t.accessIds=function(e,t){const n=e[this.mapName];return t.map(e=>n[e])},t.idExists=function(e,t){return e[this.mapName].hasOwnProperty(t)},t.accessIdList=function(e){return e[this.arrName]},t.accessList=function(e){return this.accessIds(e,this.accessIdList(e))},t.getMaxId=function(e){return this.getMeta(e,"maxId")},t.setMaxId=function(e,t,n){return this.setMeta(e,t,"maxId",n)},t.nextId=function(e){return e+1},t.getEmptyState=function(){return{...{[this.arrName]:[],[this.mapName]:{}},indexes:Object.keys(this.fields).filter(e=>e!==this.idAttribute).filter(e=>this.fields[e].index).reduce((e,t)=>({...e,[t]:{}}),{}),meta:{}}},t.setMeta=function(e,t,n,r){const{batchToken:o,withMutations:s}=e;if(s){return V.mutable.setIn(["meta",n],r,t)}return V.batch.setIn(o,["meta",n],r,t)},t.getMeta=function(e,t){return e.meta[t]},t.query=function(e,t){if(0===t.length)return this.accessList(e);const{idAttribute:n}=this,r=De()(t,e=>oe(e,n)?1:function({type:e}){return[L,Q].includes(e)}(e)?2:3),o=(t,r)=>{const{type:s,payload:i}=r;if(!t){if(oe(r,n)){const t=i[n],s=Object.keys(i).reduce((e,t)=>(t!==n&&(e[t]=i[t]),e),{}),a=this.idExists(e,t)?[t]:[];return Object.keys(s).length?o(this.accessIds(e,a),{...r,payload:s}):this.accessIds(e,a)}if(s===L&&"object"==typeof i){const t=Object.entries(e.indexes),n=[],s=[];if(t.forEach(([e,t])=>{oe(r,e)&&t.hasOwnProperty(i[e])&&(n.push(t[i[e]]),s.push(e))}),n.length){const t=n.pop(),a=n.reduce((e,t)=>{const n=new Set(t);return e.filter(Set.prototype.has,n)},t),c=Object.keys(i).reduce((e,t)=>(s.includes(t)||(e[t]=i[t]),e),{});return Object.keys(c).length?o(this.accessIds(e,a),{...r,payload:c}):this.accessIds(e,a)}}return o(this.accessList(e),r)}switch(s){case L:return xe()(t,i);case Q:return Ie()(t,i);case"REDUX_ORM_ORDER_BY":{const[e,n]=i;return Ce()(t,e,function(e){if(void 0===e)return;const t=e=>["desc",!1].includes(e)?"desc":"asc";return Array.isArray(e)?e.map(t):t(e)}(n))}default:return t}};return r.reduce(o,void 0)},t.insert=function(e,t,n){const{batchToken:r,withMutations:o}=e,s=n.hasOwnProperty(this.idAttribute);let i=t;const[a,c]=function(e,t){let n,r,o=e;return void 0===o&&(o=-1),void 0===t?(n=o+1,r=n):(n=Math.max(o+1,t),r=t),[n,r]}(this.getMaxId(t),n[this.idAttribute]);i=this.setMaxId(e,t,a);const u=s?n:V.batch.set(r,this.idAttribute,c,n),l=Object.keys(i.indexes).filter(e=>n.hasOwnProperty(e)&&null!==n[e]).map(e=>[e,n[e]]);if(o)return V.mutable.push(c,i[this.arrName]),V.mutable.set(c,u,i[this.mapName]),l.forEach(([e,t])=>{const n=i.indexes[e];n.hasOwnProperty(t)?V.mutable.push(c,n[t]):V.mutable.set(t,[c],n)}),{state:i,created:u};const d=V.batch.merge(r,l.reduce((e,[t,n])=>(e[t]=V.batch.merge(r,{[n]:V.batch.push(r,c,e[t][n]||[])},e[t]),e),{...i.indexes}),i.indexes);return{state:V.batch.merge(r,{[this.arrName]:V.batch.push(r,c,i[this.arrName]),[this.mapName]:V.batch.merge(r,{[c]:u},i[this.mapName]),indexes:d},i),created:u}},t.update=function(e,t,n,r){const{batchToken:o,withMutations:s}=e,i=s?V.mutable.set:V.batch.set(o),a=Object.keys(t.indexes).filter(e=>r.hasOwnProperty(e)),c=[],u=[],l=n.reduce((e,t)=>{const n=a.reduce((e,n)=>({...e,[n]:t[n]}),{}),l=(e=>{return(s?V.mutable.merge:V.batch.merge(o))(r,e)})(t),d=a.reduce((e,t)=>({...e,[t]:l[t]}),{}),h=l[this.idAttribute],f=i(h,l,e);return a.forEach(e=>{const{[e]:t}=n,{[e]:r}=d;t!==r&&(null!==t&&u.push([e,t,h]),null!==r&&c.push([e,r,h]))}),f},t[this.mapName]);let d=t.indexes;return s?(u.forEach(([e,t,n])=>{const r=d[e][t],o=r.indexOf(n);V.mutable.splice(o,1,[],r)}),c.forEach(([e,t,n])=>{V.mutable.push(n,d[e][t])})):(c.length&&(d=V.batch.merge(o,c.reduce((e,[t,n,r])=>(e[t]=V.batch.merge(o,{[n]:V.batch.push(o,r,e[t][n]||[])},e[t]),e),{...d}),d)),u.length&&(d=V.batch.merge(o,u.reduce((e,[t,n,r])=>(e[t]=V.batch.merge(o,{[n]:V.batch.filter(o,e=>e!==r,e[t][n])},e[t]),e),{...d}),d))),V.batch.merge(o,{[this.mapName]:l,indexes:d},t)},t.delete=function(e,t,n){const{batchToken:r,withMutations:o}=e,{arrName:s,mapName:i}=this,a=t[s],c=n.map(e=>e[this.idAttribute]);if(o)return c.forEach(e=>{const n=a.indexOf(e);V.mutable.splice(n,1,[],a),V.mutable.omit(e,t[i])}),Object.values(t.indexes).forEach(e=>Object.values(e).forEach(e=>c.forEach(t=>{const n=e.indexOf(t);-1!==n&&V.mutable.splice(n,1,[],e)}))),t;const u=V.batch.merge(r,Object.entries(t.indexes).reduce((e,[t,n])=>(e[t]=V.batch.merge(r,Object.entries(n).reduce((e,[t,n])=>(e[t]=V.batch.filter(r,e=>!c.includes(e),n),e),{...e[t]}),e[t]),e),{...t.indexes}),t.indexes);return V.batch.merge(r,{[s]:V.batch.filter(r,e=>!c.includes(e),t[s]),[i]:V.batch.omit(r,c,t[i]),indexes:V.batch.merge(r,u,t.indexes)},t)},e}();const Pe={};function Be(e,t,n){const{table:r,clauses:o}=t;return{rows:e[r].query(n[r],o)}}function Ve(e,t,n,r){const{action:o,payload:s}=t;let i,a,c;if(o===z){({table:i}=t);const o=e[i],u=r[i],l=o.insert(n,u,s);a=l.state,c=l.created}else{const{query:u}=t;({table:i}=u);const{rows:l}=Be(e,u,r),d=e[i],h=r[i];if(o===U)a=d.update(n,h,l,s),c=Be(e,u,r).rows;else{if(o!==q)throw new Error(`Database received unknown update type: ${o}`);a=d.delete(n,h,l),c=l}}const u=function(e,t,n,r){const{batchToken:o,withMutations:s}=n;return s?(r[e]=t,r):V.batch.set(o,e,t,r)}(i,a,n,r);return{status:X,state:u,payload:c}}Object.defineProperty(Pe,"@@_______REDUX_ORM_STATE_FLAG",{enumerable:!0,value:!0});var Ue=function(e){const{tables:t}=e,n=Object.entries(t).reduce((e,[t,n])=>({...e,[t]:new Te(n)}),{});return{getEmptyState:()=>Object.entries(n).reduce((e,[t,n])=>({...e,[t]:n.getEmptyState()}),Pe),query:Be.bind(null,n),update:Ve.bind(null,n),describe:e=>n[e]}};let qe=function(){function e({parent:e,orm:t}){this._parent=e,this._orm=t,this.keySelector=Y}return o()(e,[{key:"cachePath",get:function(){return[...this._parent?this._parent.cachePath:[],this.key]}},{key:"orm",get:function(){return this._orm}},{key:"parent",get:function(){return this._parent}}]),e}(),ze=function(e){function t({model:t,...n}){var r;return(r=e.call(this,n)||this)._model=t,r}return de()(t,e),o()(t,[{key:"resultFunc",get:function(){return(e,t,...n)=>{const{[this._model.modelName]:r}=e;return void 0===t?r.all().toModelArray().map(t=>this.valueForInstance(t,e,...n)):Array.isArray(t)?t.map(t=>this.valueForInstance(r.withId(t),e,...n)):this.valueForInstance(r.withId(t),e,...n)}}},{key:"model",get:function(){return this._model}}]),t}(qe);function Le(e,t){return t}let Qe=function(e){function t({field:t,selector:n,...r}){var o;return(o=e.call(this,r)||this)._field=t,o._selector=n,o}return de()(t,e),t.prototype.createResultFunc=function(e){const{idAttribute:t}=this._parent.toModel;return(n,...r)=>{const o=e(n,...r),s=Le(n,...r),i=e=>null===e?null:e.map(e=>this._selector(n,e[t]));return void 0===s||Array.isArray(s)?o.map(i):i(o)}},o()(t,[{key:"selector",get:function(){return this._selector},set:function(e){this._selector=e}},{key:"key",get:function(){return this._selector}}]),t}(ze),Xe=function(e){function t({model:t,...n}){var r;return(r=e.call(this,n)||this)._model=t,r}return de()(t,e),o()(t,[{key:"key",get:function(){return this._model.modelName}},{key:"dependencies",get:function(){return[this._orm,Le]}},{key:"resultFunc",get:function(){return({[this._model.modelName]:e},t)=>{if(void 0===t)return e.all().toRefArray();if(Array.isArray(t))return t.map(t=>{const n=e.withId(t);return n?n.ref:null});const n=e.withId(t);return n?n.ref:null}}},{key:"model",get:function(){return this._model}}]),t}(qe),He=function(e){function t({field:t,fieldModel:n,accessorName:r,isVirtual:o,...s}){var i;return(i=e.call(this,s)||this)._field=t,i._fieldModel=n,i._accessorName=r,i._isVirtual=o,i}de()(t,e);var n=t.prototype;return n.valueForInstance=function(e,t){if(!e)return null;let n;if(this._parent instanceof Xe)n=e[this._accessorName];else{const{[this._parent.toModelName]:r}=t,o=this._parent.valueForInstance(e,t),s=o?new r(o):null;n=s?s[this._accessorName]:null}return n instanceof Ee?n.ref:n instanceof ce?n.toRefArray():n},n.map=function(e){if(e instanceof Xe)throw this.toModelName===e.model.modelName?new Error(`Cannot select models in a \`map()\` call. If you just want the \`${this._accessorName}\` as a ref array then you can simply drop the \`map()\`. Otherwise make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`):new Error(`Cannot select \`${e.model.modelName}\` models in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`);if(e instanceof t||e instanceof Qe){if(this.toModelName!==e.model.modelName)throw new Error(`Cannot select fields of the \`${e.model.modelName}\` model in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`)}else if(!e||"function"!=typeof e||!e.recomputations)throw new Error(`\`map()\` requires a selector as an input. Received: ${JSON.stringify(e)} of type ${typeof e}`);if(!(this._field instanceof be||this._field instanceof we))throw new Error("Cannot map selectors for non-collection fields");return new Qe({parent:this,model:this._model,orm:this._orm,field:this._field,selector:e})},o()(t,[{key:"key",get:function(){return this._accessorName}},{key:"dependencies",get:function(){return[this._orm,Le]}},{key:"toModelName",get:function(){return"this"===this._field.toModelName?this._fieldModel.modelName:this._field.toModelName}},{key:"toModel",get:function(){return this._orm.getDatabase().describe(this.toModelName)}}]),t}(ze);function Ye({parent:e,model:t,field:n,fieldModel:r,accessorName:o,orm:s,isVirtual:i}){const a=new He({parent:e,model:t,field:n,fieldModel:r,accessorName:o,orm:s,isVirtual:i});if(!(n instanceof ge))return a;if(e instanceof He&&(e._field instanceof be&&e._isVirtual||e._field instanceof we))throw new Error(`Cannot create a selector for \`${e._accessorName}.${o}\` because \`${e._accessorName}\` is a collection field.`);const{toModelName:c}=n,u=s.get("this"===c?t.modelName:c);return Object.entries(u.fields).forEach(([e,n])=>{const r=n.as||e;Object.defineProperty(a,r,{get:()=>Ye({parent:a,model:t,fieldModel:u,field:n,accessorName:r,orm:s,isVirtual:!1})})}),Object.entries(u.virtualFields).forEach(([e,n])=>{const r=n.as||e;a.hasOwnProperty(r)||Object.defineProperty(a,r,{get:()=>Ye({parent:a,model:t,fieldModel:u,field:n,accessorName:r,orm:s,isVirtual:!0})})}),a}const Ke={createDatabase:Ue},Ge=["indexes","meta"],Je=e=>Ge.includes(e);let We=function(){function e(e){const{createDatabase:t}={...Ke,...e||{}};this.createDatabase=t,this.registry=[],this.implicitThroughModels=[],this.installedFields={},this.stateSelector=e?e.stateSelector:null}var t=e.prototype;return t.register=function(...e){e.forEach(e=>{if(void 0===e.modelName)throw new Error("A model was passed that doesn't have a modelName set");e.invalidateClassCache(),this.registerManyToManyModelsFor(e),this.registry.push(e),Object.defineProperty(this,e.modelName,{get:()=>(this._setupModelPrototypes(this.registry),function({model:e,orm:t}){const n=new Xe({parent:null,orm:t,model:e});return Object.entries(e.fields).forEach(([r,o])=>{const s=o.as||r;Object.defineProperty(n,s,{get:()=>Ye({parent:n,model:e,fieldModel:e,field:o,accessorName:s,orm:t,isVirtual:!1})})}),Object.entries(e.virtualFields).forEach(([r,o])=>{const s=o.as||r;n.hasOwnProperty(s)||Object.defineProperty(n,s,{get:()=>Ye({parent:n,model:e,fieldModel:e,field:o,accessorName:s,orm:t,isVirtual:!0})})}),n}({model:e,orm:this}))})})},t.registerManyToManyModelsFor=function(e){const{fields:t}=e,n=e.modelName;Object.entries(t).forEach(([e,t])=>{if(!(t instanceof we))return;let r;r="this"===t.toModelName?n:t.toModelName;const s=n===r,i=J(n),a=W(r);if(t.through){if(s&&!t.throughFields)throw new Error("Self-referencing many-to-many relationship at "+`"${n}.${e}" using custom `+`model "${t.through}" has no `+"throughFields key. Cannot determine which fields reference the instances partaking in the relationship.")}else{const t=function(e){function t(){return e.apply(this,arguments)||this}return de()(t,e),t}(Ee);t.modelName=G(n,e);const c=function(e){function t(){return e.apply(this,arguments)||this}return de()(t,e),o()(t,[{key:"installsBackwardsVirtualField",get:function(){return!1}},{key:"installsBackwardsDescriptor",get:function(){return!1}}]),t}(be),u=s?c:be;t.fields={id:_e(),[i]:new u(n),[a]:new u(r)},t.invalidateClassCache(),this.implicitThroughModels.push(t)}})},t.get=function(e){const t=this.registry.concat(this.implicitThroughModels),n=Object.values(t).find(t=>t.modelName===e);if(void 0===n)throw new Error(`Did not find model ${e} from registry.`);return n},t.getModelClasses=function(){return this._setupModelPrototypes(this.registry),this._setupModelPrototypes(this.implicitThroughModels),this.registry.concat(this.implicitThroughModels)},t.generateSchemaSpec=function(){return{tables:this.getModelClasses().reduce((e,t)=>{const n=t.modelName,r=t.tableOptions();return Object.keys(r).filter(Je).forEach(e=>{throw new Error(`Reserved keyword \`${e}\` used in ${n}.options.`)}),e[n]={fields:{...t.fields},...r},e},{})}},t.getDatabase=function(){return this.db||(this.db=this.createDatabase(this.generateSchemaSpec())),this.db},t.getEmptyState=function(){return this.getDatabase().getEmptyState()},t.session=function(e){return new ue(this,this.getDatabase(),e)},t.mutableSession=function(e){return new ue(this,this.getDatabase(),e,!0)},t._setupModelPrototypes=function(e){e.filter(e=>!e.isSetUp).forEach(e=>{const{fields:t,modelName:n,querySetClass:r}=e;Object.entries(t).forEach(([t,r])=>{if(!(r instanceof fe))throw new Error(`${n}.${t} is of type "${typeof r}" `+"but must be an instance of Field. Please use the `attr`, `fk`, `oneToOne` and `many` functions to define fields.");this._isFieldInstalled(n,t)||(this._installField(r,t,e),this._setFieldInstalled(n,t))}),te(e,r),e.isSetUp=!0})},t._isFieldInstalled=function(e,t){return!!this.installedFields.hasOwnProperty(e)&&!!this.installedFields[e][t]},t._setFieldInstalled=function(e,t){this.installedFields.hasOwnProperty(e)||(this.installedFields[e]={}),this.installedFields[e][t]=!0},t._installField=function(e,t,n){new(0,e.installerClass)({field:e,fieldName:t,model:n,orm:this}).run()},t.withMutations=function(e){return K("`ORM.prototype.withMutations` has been deprecated. Use `ORM.prototype.mutableSession` instead."),this.mutableSession(e)},t.from=function(e){return K("`ORM.prototype.from` has been deprecated. Use `ORM.prototype.session` instead."),this.session(e)},t.getDefaultState=function(){return K("`ORM.prototype.getDefaultState` has been deprecated. Use `ORM.prototype.getEmptyState` instead."),this.getEmptyState()},t.define=function(){throw new Error("`ORM.prototype.define` has been removed. Please define a Model class.")},e}();var Ze=n(4),et=n(5),tt=n.n(et);const nt=(e,t)=>e===t,rt=e=>e&&"object"==typeof e&&e.hasOwnProperty("@@_______REDUX_ORM_STATE_FLAG"),ot=(e,t,n)=>t.every((t,r)=>rt(t)&&rt(e[r])||n(t,e[r])),st=(e,t,n)=>{const{accessedInstances:r}=e;return Object.entries(r).every(([r,o])=>{if(e.ormState[r]===t[r])return!0;const{mapName:s}=n.getDatabase().describe(r),{[s]:i}=e.ormState[r],{[s]:a}=t[r];return((e,t,n)=>e.every(e=>t[e]===n[e]))(Object.keys(o),i,a)})},it=(e,t)=>{const{accessedIndexes:n}=e;return Object.entries(n).every(([n,r])=>Object.entries(r).every(([r,o])=>o.every(o=>e.ormState[n].indexes[r][o]===t[n].indexes[r][o])))},at=(e,t)=>e.fullTableScannedModels.every(n=>e.ormState[n]===t[n]);function ct(e,t=nt,n){let r={result:null,args:null,ormState:null,fullTableScannedModels:[],accessedInstances:{},accessedIndexes:{}};return(...o)=>{const[s,...i]=o;if(Boolean(r.args)&&ot(r.args,i,t)&&at(r,s)&&it(r,s)&&st(r,s,n))return r.result;const a=n.session(s),c=i.map(e=>rt(e)?a:e),u=e.apply(null,c);return r={args:i,result:u,ormState:s,accessedInstances:a.accessedModelInstances,accessedIndexes:a.accessedIndexes,fullTableScannedModels:a.fullTableScannedModels},u}}function ut(e,t){e.sessionBoundModels.forEach(n=>{"function"==typeof n.reducer&&n.reducer(t,n,e)})}function lt(e,t=ut){return(n,r)=>{const o=e.session(n||e.getEmptyState());return t(o,r),o.state}}function dt(e){return e instanceof We?e:e instanceof qe&&e._orm}const ht=new Map,ft=Symbol.for("REDUX_ORM_SELECTOR");function pt(e){if("function"==typeof e)return e;if(e instanceof We)return e.stateSelector;if(e instanceof Qe&&(e.selector=pt(e.selector)),e instanceof qe){const{orm:t,cachePath:n}=e;let r;ht.has(t)||ht.set(t,new Map),r=ht.get(t);for(let e=0;e<n.length;++e){const t=n[e];r.has(t)||r.set(t,new Map),r=r.get(t)}if(r&&r.has(ft))return r.get(ft);const o=function e(t){if(t instanceof Qe){const n=e(t.parent);return t.createResultFunc(n)}return tt()(t.dependencies,t.resultFunc)({keySelector:t.keySelector,cacheObject:new et.FlatMapCache,selectorCreator:mt})}(e);return r.set(ft,o),o}throw new Error(`Failed to interpret selector argument: ${JSON.stringify(e)} of type ${typeof e}`)}function mt(...e){if(!e.length)throw new Error("Cannot create a selector without arguments.");const t=e.pop(),n=Array.isArray(e[0])?e[0]:e,r=n.map(dt).find(Boolean),o=n.map(pt);if("function"==typeof t){if(!r)throw new Error("Failed to resolve the current ORM database state. Please pass an ORM instance or an ORM selector as an argument to `createSelector()`.");if(!r.stateSelector)throw new Error("Failed to resolve the current ORM database state. Please pass an object to the ORM constructor that specifies a `stateSelector` function.");if("function"!=typeof r.stateSelector)throw new Error(`Failed to resolve the current ORM database state. Please pass a function when specifying the ORM's \`stateSelector\`. Received: ${JSON.stringify(r.stateSelector)} of type ${typeof r.stateSelector}`);return Object(Ze.createSelectorCreator)(ct,void 0,r)([r.stateSelector,...o],t)}if(t instanceof We)throw new Error("ORM instances cannot be the result function of selectors. You can access your models in the last function that you pass to `createSelector()`.");return o.length&&console.warn("Your input selectors will be ignored: the passed result function does not require any input."),pt(t)}n.d(t,"Schema",(function(){return yt})),n.d(t,"Backend",(function(){return gt})),n.d(t,"Attribute",(function(){return ye})),n.d(t,"QuerySet",(function(){return ce})),n.d(t,"Model",(function(){return Ee})),n.d(t,"ORM",(function(){return We})),n.d(t,"Session",(function(){return ue})),n.d(t,"ForeignKey",(function(){return be})),n.d(t,"ManyToMany",(function(){return we})),n.d(t,"OneToOne",(function(){return ve})),n.d(t,"fk",(function(){return Me})),n.d(t,"many",(function(){return Oe})),n.d(t,"attr",(function(){return _e})),n.d(t,"oneToOne",(function(){return Ne})),n.d(t,"createReducer",(function(){return lt})),n.d(t,"createSelector",(function(){return mt}));const yt=function(){throw new Error("Schema has been renamed to ORM. Please import ORM instead of Schema from Redux-ORM.")},gt=function(){throw new Error("Having a custom Backend instance is now unsupported. Documentation for database customization is upcoming, for now please look at the db folder in the source.")};t.default=Ee}])}));
//# sourceMappingURL=redux-orm.min.js.map

@@ -93,3 +93,2 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

function toSelector(arg) {
/* eslint-disable no-underscore-dangle */
if (typeof arg === "function") {

@@ -104,7 +103,8 @@ return arg;

if (arg instanceof MapSelectorSpec) {
arg._selector = toSelector(arg._selector);
// the argument to map() needs to be callable
arg.selector = toSelector(arg.selector);
}
if (arg instanceof SelectorSpec) {
var orm = arg._orm,
var orm = arg.orm,
cachePath = arg.cachePath;

@@ -128,7 +128,9 @@ var level; // the selector cache for the spec's ORM

for (var i = 0; i < cachePath.length; ++i) {
if (!level.has(cachePath[i])) {
level.set(cachePath[i], new Map());
var storageKey = cachePath[i];
if (!level.has(storageKey)) {
level.set(storageKey, new Map());
}
level = level.get(cachePath[i]);
level = level.get(storageKey);
}

@@ -139,4 +141,5 @@

return level.get(SELECTOR_KEY);
}
} // Cache miss: the selector needs to be created
var selector = createSelectorFromSpec(arg); // Save the selector at the cachePath position

@@ -143,0 +146,0 @@

@@ -39,3 +39,6 @@ import _typeof from "@babel/runtime/helpers/typeof";

_proto.valueForInstance = function valueForInstance(instance, session) {
if (!instance) return null;
if (!instance) {
return null;
}
var value;

@@ -68,12 +71,11 @@

_proto.map = function map(selector) {
/* eslint-disable no-underscore-dangle */
if (selector instanceof ModelSelectorSpec) {
if (this.toModelName === selector._model.modelName) {
if (this.toModelName === selector.model.modelName) {
throw new Error("Cannot select models in a `map()` call. If you just want the `".concat(this._accessorName, "` as a ref array then you can simply drop the `map()`. Otherwise make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
} else {
throw new Error("Cannot select `".concat(selector._model.modelName, "` models in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
throw new Error("Cannot select `".concat(selector.model.modelName, "` models in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
}
} else if (selector instanceof FieldSelectorSpec || selector instanceof MapSelectorSpec) {
if (this.toModelName !== selector._model.modelName) {
throw new Error("Cannot select fields of the `".concat(selector._model.modelName, "` model in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
if (this.toModelName !== selector.model.modelName) {
throw new Error("Cannot select fields of the `".concat(selector.model.modelName, "` model in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
}

@@ -112,2 +114,9 @@ } else if (!selector || typeof selector !== "function" || !selector.recomputations) {

}
}, {
key: "toModel",
get: function get() {
var db = this._orm.getDatabase();
return db.describe(this.toModelName);
}
}]);

@@ -114,0 +123,0 @@

@@ -30,5 +30,4 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

var idAttribute = this._parent.toModel.idAttribute;
return function (state) {
var _this2$_orm;
for (var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

@@ -38,19 +37,26 @@ other[_key - 1] = arguments[_key];

/**
* The parent selector should return a ref array
* in case of a single ID being passed.
* Otherwise it should return an array of ref arrays.
*/
var parentResult = parentSelector.apply(void 0, [state].concat(other));
if (parentResult === null) return null;
var idArg = idArgSelector.apply(void 0, [state].concat(other));
var ormState = (_this2$_orm = _this2._orm).stateSelector.apply(_this2$_orm, [state].concat(other));
var single = function single(refArray) {
if (refArray === null) {
// an intermediate field could not be resolved
return null;
}
var session = _this2._orm.session(ormState);
return refArray.map(function (ref) {
return _this2._selector(state, ref[idAttribute]);
});
};
var idArg = idArgSelector.apply(void 0, [state].concat(other));
var idAttribute = session[_this2._field.toModelName].idAttribute;
if (typeof idArg === "undefined" || Array.isArray(idArg)) {
return parentResult.map(function (ref) {
return ref === null ? null : _this2._selector(state, ref[idAttribute]);
});
return parentResult.map(single);
}
return _this2._selector(state, parentResult[idAttribute]);
return single(parentResult);
};

@@ -60,6 +66,14 @@ };

_createClass(MapSelectorSpec, [{
key: "parent",
key: "selector",
get: function get() {
return this._parent;
return this._selector;
},
set: function set(selector) {
this._selector = selector;
}
}, {
key: "key",
get: function get() {
return this._selector;
}
}]);

@@ -66,0 +80,0 @@

@@ -49,2 +49,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

}
}, {
key: "model",
get: function get() {
return this._model;
}
}]);

@@ -51,0 +56,0 @@

@@ -56,2 +56,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

}
}, {
key: "model",
get: function get() {
return this._model;
}
}]);

@@ -58,0 +63,0 @@

@@ -22,2 +22,12 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";

}
}, {
key: "orm",
get: function get() {
return this._orm;
}
}, {
key: "parent",
get: function get() {
return this._parent;
}
}]);

@@ -24,0 +34,0 @@

@@ -115,3 +115,2 @@ "use strict";

function toSelector(arg) {
/* eslint-disable no-underscore-dangle */
if (typeof arg === "function") {

@@ -126,7 +125,8 @@ return arg;

if (arg instanceof _MapSelectorSpec["default"]) {
arg._selector = toSelector(arg._selector);
// the argument to map() needs to be callable
arg.selector = toSelector(arg.selector);
}
if (arg instanceof _SelectorSpec["default"]) {
var orm = arg._orm,
var orm = arg.orm,
cachePath = arg.cachePath;

@@ -150,7 +150,9 @@ var level; // the selector cache for the spec's ORM

for (var i = 0; i < cachePath.length; ++i) {
if (!level.has(cachePath[i])) {
level.set(cachePath[i], new Map());
var storageKey = cachePath[i];
if (!level.has(storageKey)) {
level.set(storageKey, new Map());
}
level = level.get(cachePath[i]);
level = level.get(storageKey);
}

@@ -161,4 +163,5 @@

return level.get(SELECTOR_KEY);
}
} // Cache miss: the selector needs to be created
var selector = createSelectorFromSpec(arg); // Save the selector at the cachePath position

@@ -165,0 +168,0 @@

@@ -58,3 +58,6 @@ "use strict";

_proto.valueForInstance = function valueForInstance(instance, session) {
if (!instance) return null;
if (!instance) {
return null;
}
var value;

@@ -87,12 +90,11 @@

_proto.map = function map(selector) {
/* eslint-disable no-underscore-dangle */
if (selector instanceof _ModelSelectorSpec["default"]) {
if (this.toModelName === selector._model.modelName) {
if (this.toModelName === selector.model.modelName) {
throw new Error("Cannot select models in a `map()` call. If you just want the `".concat(this._accessorName, "` as a ref array then you can simply drop the `map()`. Otherwise make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
} else {
throw new Error("Cannot select `".concat(selector._model.modelName, "` models in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
throw new Error("Cannot select `".concat(selector.model.modelName, "` models in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
}
} else if (selector instanceof FieldSelectorSpec || selector instanceof _MapSelectorSpec["default"]) {
if (this.toModelName !== selector._model.modelName) {
throw new Error("Cannot select fields of the `".concat(selector._model.modelName, "` model in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
if (this.toModelName !== selector.model.modelName) {
throw new Error("Cannot select fields of the `".concat(selector.model.modelName, "` model in this `map()` call. Make sure you're passing a field selector of the form `").concat(this.toModelName, ".<field>` or a custom selector instead."));
}

@@ -131,2 +133,9 @@ } else if (!selector || typeof selector !== "function" || !selector.recomputations) {

}
}, {
key: "toModel",
get: function get() {
var db = this._orm.getDatabase();
return db.describe(this.toModelName);
}
}]);

@@ -133,0 +142,0 @@ return FieldSelectorSpec;

@@ -42,5 +42,4 @@ "use strict";

var idAttribute = this._parent.toModel.idAttribute;
return function (state) {
var _this2$_orm;
for (var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

@@ -50,20 +49,27 @@ other[_key - 1] = arguments[_key];

/**
* The parent selector should return a ref array
* in case of a single ID being passed.
* Otherwise it should return an array of ref arrays.
*/
var parentResult = parentSelector.apply(void 0, [state].concat(other));
if (parentResult === null) return null;
var ormState = (_this2$_orm = _this2._orm).stateSelector.apply(_this2$_orm, [state].concat(other));
var idArg = _idArgSelector["default"].apply(void 0, [state].concat(other));
var session = _this2._orm.session(ormState);
var single = function single(refArray) {
if (refArray === null) {
// an intermediate field could not be resolved
return null;
}
var idArg = _idArgSelector["default"].apply(void 0, [state].concat(other));
return refArray.map(function (ref) {
return _this2._selector(state, ref[idAttribute]);
});
};
var idAttribute = session[_this2._field.toModelName].idAttribute;
if (typeof idArg === "undefined" || Array.isArray(idArg)) {
return parentResult.map(function (ref) {
return ref === null ? null : _this2._selector(state, ref[idAttribute]);
});
return parentResult.map(single);
}
return _this2._selector(state, parentResult[idAttribute]);
return single(parentResult);
};

@@ -73,6 +79,14 @@ };

(0, _createClass2["default"])(MapSelectorSpec, [{
key: "parent",
key: "selector",
get: function get() {
return this._parent;
return this._selector;
},
set: function set(selector) {
this._selector = selector;
}
}, {
key: "key",
get: function get() {
return this._selector;
}
}]);

@@ -79,0 +93,0 @@ return MapSelectorSpec;

@@ -60,2 +60,7 @@ "use strict";

}
}, {
key: "model",
get: function get() {
return this._model;
}
}]);

@@ -62,0 +67,0 @@ return ModelBasedSelectorSpec;

@@ -68,2 +68,7 @@ "use strict";

}
}, {
key: "model",
get: function get() {
return this._model;
}
}]);

@@ -70,0 +75,0 @@ return ModelSelectorSpec;

@@ -33,2 +33,12 @@ "use strict";

}
}, {
key: "orm",
get: function get() {
return this._orm;
}
}, {
key: "parent",
get: function get() {
return this._parent;
}
}]);

@@ -35,0 +45,0 @@ return SelectorSpec;

{
"name": "redux-orm",
"version": "0.16.0",
"version": "0.16.1",
"description": "Simple ORM to manage and query your state trees",

@@ -37,21 +37,25 @@ "main": "lib/index.js",

},
"bugs": {
"url": "https://github.com/redux-orm/redux-orm/issues"
},
"homepage": "https://redux-orm.github.io/redux-orm",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-proposal-export-namespace-from": "^7.7.4",
"@babel/plugin-proposal-function-sent": "^7.7.4",
"@babel/plugin-proposal-json-strings": "^7.7.4",
"@babel/plugin-proposal-numeric-separator": "^7.7.4",
"@babel/plugin-proposal-throw-expressions": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/plugin-syntax-import-meta": "^7.7.4",
"@babel/plugin-transform-classes": "^7.7.4",
"@babel/plugin-transform-destructuring": "^7.7.4",
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.6",
"@babel/register": "^7.7.4",
"@babel/cli": "^7.8.0",
"@babel/core": "^7.8.0",
"@babel/plugin-proposal-class-properties": "^7.8.0",
"@babel/plugin-proposal-decorators": "^7.8.0",
"@babel/plugin-proposal-export-namespace-from": "^7.8.0",
"@babel/plugin-proposal-function-sent": "^7.8.0",
"@babel/plugin-proposal-json-strings": "^7.8.0",
"@babel/plugin-proposal-numeric-separator": "^7.8.0",
"@babel/plugin-proposal-throw-expressions": "^7.8.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-syntax-import-meta": "^7.8.0",
"@babel/plugin-transform-classes": "^7.8.0",
"@babel/plugin-transform-destructuring": "^7.8.0",
"@babel/plugin-transform-modules-commonjs": "^7.8.0",
"@babel/plugin-transform-runtime": "^7.8.0",
"@babel/preset-env": "^7.8.0",
"@babel/register": "^7.8.0",
"@types/jsdoc-to-markdown": "^4.0.0",

@@ -66,12 +70,10 @@ "babel-core": "^7.0.0-bridge.0",

"deep-freeze": "0.0.1",
"eslint": "^6.7.2",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jest": "^23.1.1",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jest": "^23.6.0",
"eslint-plugin-prettier": "^3.1.2",
"gulp": "^4.0.2",
"gulp-clean": "^0.4.0",
"gulp-gh-pages": "https://github.com/tekd/gulp-gh-pages/tarball/9ebafeb4011982c98038d8e90373fe7ed91e3f88",
"gulp-rename": "^1.4.0",
"jest": "^24.9.0",

@@ -82,7 +84,7 @@ "jest-cli": "^24.9.0",

"lodash-webpack-plugin": "^0.11.5",
"redux": "^4.0.4",
"prettier": "^1.19.1",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"prettier": "^1.19.1",
"rimraf": "^3.0.0",
"webpack": "^4.41.3",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",

@@ -92,3 +94,3 @@ "webpack-merge": "^4.2.2"

"dependencies": {
"@babel/runtime": "^7.7.6",
"@babel/runtime": "^7.8.0",
"immutable-ops": "^0.7.0",

@@ -95,0 +97,0 @@ "lodash": "^4.17.15",

@@ -90,3 +90,2 @@ import { createSelectorCreator } from "reselect";

function toSelector(arg) {
/* eslint-disable no-underscore-dangle */
if (typeof arg === "function") {

@@ -99,6 +98,7 @@ return arg;

if (arg instanceof MapSelectorSpec) {
arg._selector = toSelector(arg._selector);
// the argument to map() needs to be callable
arg.selector = toSelector(arg.selector);
}
if (arg instanceof SelectorSpec) {
const { _orm: orm, cachePath } = arg;
const { orm, cachePath } = arg;
let level;

@@ -120,6 +120,7 @@

for (let i = 0; i < cachePath.length; ++i) {
if (!level.has(cachePath[i])) {
level.set(cachePath[i], new Map());
const storageKey = cachePath[i];
if (!level.has(storageKey)) {
level.set(storageKey, new Map());
}
level = level.get(cachePath[i]);
level = level.get(storageKey);
}

@@ -130,5 +131,4 @@ if (level && level.has(SELECTOR_KEY)) {

}
// Cache miss: the selector needs to be created
const selector = createSelectorFromSpec(arg);
// Save the selector at the cachePath position

@@ -135,0 +135,0 @@ level.set(SELECTOR_KEY, selector);

@@ -30,3 +30,5 @@ import MapSelectorSpec from "./MapSelectorSpec";

valueForInstance(instance, session) {
if (!instance) return null;
if (!instance) {
return null;
}
let value;

@@ -55,5 +57,4 @@ if (this._parent instanceof ModelSelectorSpec) {

map(selector) {
/* eslint-disable no-underscore-dangle */
if (selector instanceof ModelSelectorSpec) {
if (this.toModelName === selector._model.modelName) {
if (this.toModelName === selector.model.modelName) {
throw new Error(

@@ -64,3 +65,3 @@ `Cannot select models in a \`map()\` call. If you just want the \`${this._accessorName}\` as a ref array then you can simply drop the \`map()\`. Otherwise make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`

throw new Error(
`Cannot select \`${selector._model.modelName}\` models in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`
`Cannot select \`${selector.model.modelName}\` models in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`
);

@@ -72,5 +73,5 @@ }

) {
if (this.toModelName !== selector._model.modelName) {
if (this.toModelName !== selector.model.modelName) {
throw new Error(
`Cannot select fields of the \`${selector._model.modelName}\` model in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`
`Cannot select fields of the \`${selector.model.modelName}\` model in this \`map()\` call. Make sure you're passing a field selector of the form \`${this.toModelName}.<field>\` or a custom selector instead.`
);

@@ -109,2 +110,7 @@ }

}
get toModel() {
const db = this._orm.getDatabase();
return db.describe(this.toModelName);
}
}

@@ -11,27 +11,39 @@ import ModelBasedSelectorSpec from "./ModelBasedSelectorSpec";

get parent() {
return this._parent;
}
createResultFunc(parentSelector) {
const { idAttribute } = this._parent.toModel;
return (state, ...other) => {
/**
* The parent selector should return a ref array
* in case of a single ID being passed.
* Otherwise it should return an array of ref arrays.
*/
const parentResult = parentSelector(state, ...other);
if (parentResult === null) return null;
const ormState = this._orm.stateSelector(state, ...other);
const session = this._orm.session(ormState);
const idArg = idArgSelector(state, ...other);
const {
[this._field.toModelName]: { idAttribute },
} = session;
const single = refArray => {
if (refArray === null) {
// an intermediate field could not be resolved
return null;
}
return refArray.map(ref =>
this._selector(state, ref[idAttribute])
);
};
if (typeof idArg === "undefined" || Array.isArray(idArg)) {
return parentResult.map(ref =>
ref === null
? null
: this._selector(state, ref[idAttribute])
);
return parentResult.map(single);
}
return this._selector(state, parentResult[idAttribute]);
return single(parentResult);
};
}
get selector() {
return this._selector;
}
set selector(selector) {
this._selector = selector;
}
get key() {
return this._selector;
}
}

@@ -35,2 +35,6 @@ import SelectorSpec from "./SelectorSpec";

}
get model() {
return this._model;
}
}

@@ -33,2 +33,6 @@ import SelectorSpec from "./SelectorSpec";

}
get model() {
return this._model;
}
}

@@ -14,2 +14,10 @@ import { ID_ARG_KEY_SELECTOR } from "../constants";

}
get orm() {
return this._orm;
}
get parent() {
return this._parent;
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc