react-achievements 2.0.5 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -2
- package/dist/hooks/useAchievement.d.ts +1 -1
- package/dist/hooks/useAchievementState.d.ts +4 -0
- package/dist/index.cjs.js +298 -221
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +302 -226
- package/dist/providers/AchievementProvider.d.ts +4 -4
- package/dist/redux/achievementSlice.d.ts +13 -7
- package/dist/types.d.ts +13 -2
- package/package.json +10 -11
- package/rollup.config.mjs +6 -0
- package/src/hooks/useAchievementState.ts +12 -0
- package/src/index.ts +2 -0
- package/src/providers/AchievementProvider.tsx +138 -102
- package/src/redux/achievementSlice.ts +35 -8
- package/src/types.ts +14 -2
package/dist/index.cjs.js
CHANGED
|
@@ -22,8 +22,6 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
|
|
23
23
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
24
24
|
|
|
25
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
26
|
-
|
|
27
25
|
function getDefaultExportFromCjs (x) {
|
|
28
26
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
29
27
|
}
|
|
@@ -39,7 +37,7 @@ var useSyncExternalStoreShim_production = {};
|
|
|
39
37
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
38
|
*
|
|
41
39
|
* This source code is licensed under the MIT license found in the
|
|
42
|
-
* LICENSE file in the root directory of
|
|
40
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
43
41
|
*/
|
|
44
42
|
|
|
45
43
|
var hasRequiredUseSyncExternalStoreShim_production;
|
|
@@ -114,7 +112,7 @@ var useSyncExternalStoreShim_development = {};
|
|
|
114
112
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
115
113
|
*
|
|
116
114
|
* This source code is licensed under the MIT license found in the
|
|
117
|
-
* LICENSE file in the root directory of
|
|
115
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
118
116
|
*/
|
|
119
117
|
|
|
120
118
|
var hasRequiredUseSyncExternalStoreShim_development;
|
|
@@ -228,7 +226,7 @@ var withSelector_production = {};
|
|
|
228
226
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
229
227
|
*
|
|
230
228
|
* This source code is licensed under the MIT license found in the
|
|
231
|
-
* LICENSE file in the root directory of
|
|
229
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
232
230
|
*/
|
|
233
231
|
|
|
234
232
|
var hasRequiredWithSelector_production;
|
|
@@ -322,7 +320,7 @@ var withSelector_development = {};
|
|
|
322
320
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
323
321
|
*
|
|
324
322
|
* This source code is licensed under the MIT license found in the
|
|
325
|
-
* LICENSE file in the root directory of
|
|
323
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
326
324
|
*/
|
|
327
325
|
|
|
328
326
|
var hasRequiredWithSelector_development;
|
|
@@ -641,7 +639,7 @@ var reactIs_production_min$1 = {};
|
|
|
641
639
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
642
640
|
*
|
|
643
641
|
* This source code is licensed under the MIT license found in the
|
|
644
|
-
* LICENSE file in the root directory of
|
|
642
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
645
643
|
*/
|
|
646
644
|
|
|
647
645
|
var hasRequiredReactIs_production_min$1;
|
|
@@ -666,7 +664,7 @@ var reactIs_development$1 = {};
|
|
|
666
664
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
667
665
|
*
|
|
668
666
|
* This source code is licensed under the MIT license found in the
|
|
669
|
-
* LICENSE file in the root directory of
|
|
667
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
670
668
|
*/
|
|
671
669
|
|
|
672
670
|
var hasRequiredReactIs_development$1;
|
|
@@ -884,7 +882,7 @@ var reactIs_production_min = {};
|
|
|
884
882
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
885
883
|
*
|
|
886
884
|
* This source code is licensed under the MIT license found in the
|
|
887
|
-
* LICENSE file in the root directory of
|
|
885
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
888
886
|
*/
|
|
889
887
|
|
|
890
888
|
var hasRequiredReactIs_production_min;
|
|
@@ -909,7 +907,7 @@ var reactIs_development = {};
|
|
|
909
907
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
910
908
|
*
|
|
911
909
|
* This source code is licensed under the MIT license found in the
|
|
912
|
-
* LICENSE file in the root directory of
|
|
910
|
+
* LICENSE file in the root directory of undefined source tree.
|
|
913
911
|
*/
|
|
914
912
|
|
|
915
913
|
var hasRequiredReactIs_development;
|
|
@@ -922,7 +920,7 @@ function requireReactIs_development () {
|
|
|
922
920
|
(function() {
|
|
923
921
|
|
|
924
922
|
// ATTENTION
|
|
925
|
-
// When adding new symbols to
|
|
923
|
+
// When adding new symbols to undefined file,
|
|
926
924
|
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
927
925
|
// The Symbol used to tag the ReactElement-like types.
|
|
928
926
|
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
@@ -971,7 +969,7 @@ function requireReactIs_development () {
|
|
|
971
969
|
if (typeof type === 'object' && type !== null) {
|
|
972
970
|
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
973
971
|
// types supported by any Flight configuration anywhere since
|
|
974
|
-
// we don't know which Flight build
|
|
972
|
+
// we don't know which Flight build undefined will end up being used
|
|
975
973
|
// with.
|
|
976
974
|
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
977
975
|
return true;
|
|
@@ -1217,9 +1215,9 @@ const useDispatch = /*#__PURE__*/createDispatchHook();
|
|
|
1217
1215
|
// Because of that, the useSyncExternalStore compat shim is needed.
|
|
1218
1216
|
initializeUseSelector(withSelectorExports.useSyncExternalStoreWithSelector);
|
|
1219
1217
|
|
|
1220
|
-
function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return false;var r=Object.getPrototypeOf(n);if(null===r)return true;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){ void 0===t&&(t=false),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];false===o.writable&&(o.writable=true,o.configurable=true),(o.get||o.set)&&(r[i]={configurable:true,writable:true,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=false),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,true)}),true)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function m(n,r){tn[n]||(tn[n]=r);}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:true,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=true;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),true),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,true),e.t;if(!e.I){e.I=true,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=false;3===e.i&&(u=new Set(o),o.clear(),a=true),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,false),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=false;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){ void 0===t&&(t=false),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=true,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:false,I:false,R:{},l:r,t:n,k:null,o:null,j:null,C:false},i=e,o=en;t&&(i=[e],o=on$1);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=true,e=D(r,c),u.I=false;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function F(){function t(n,r){var t=s[n];return t?t.enumerable=r:s[n]=t={configurable:true,enumerable:r,get:function(){var r=this[Q];return "production"!==process.env.NODE_ENV&&f(r),en.get(r,n)},set:function(r){var t=this[Q];"production"!==process.env.NODE_ENV&&f(t),en.set(t,n,r);}},t}function e(n){for(var r=n.length-1;r>=0;r--){var t=n[r][Q];if(!t.P)switch(t.i){case 5:a(t)&&k(t);break;case 4:o(t)&&k(t);}}}function o(n){for(var r=n.t,t=n.k,e=nn(t),i=e.length-1;i>=0;i--){var o=e[i];if(o!==Q){var a=r[o];if(void 0===a&&!u(r,o))return true;var f=t[o],s=f&&f[Q];if(s?s.t!==a:!c(f,a))return true}}var v=!!r[Q];return e.length!==nn(r).length+(v?0:1)}function a(n){var r=n.k;if(r.length!==n.t.length)return true;var t=Object.getOwnPropertyDescriptor(r,r.length-1);if(t&&!t.get)return true;for(var e=0;e<r.length;e++)if(!r.hasOwnProperty(e))return true;return false}function f(r){r.g&&n(3,JSON.stringify(p(r)));}var s={};m("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,true));return e}var o=rn(r);delete o[Q];for(var u=nn(o),a=0;a<u.length;a++){var f=u[a];o[f]=t(f,n||!!o[f].enumerable);}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:_(),P:false,I:false,R:{},l:r,t:n,k:i,o:null,g:false,C:false};return Object.defineProperty(i,Q,{value:o,writable:true}),i},S:function(n,t,o){o?r(t)&&t[Q].A===n&&e(n.p):(n.u&&function n(r){if(r&&"object"==typeof r){var t=r[Q];if(t){var e=t.t,o=t.k,f=t.R,c=t.i;if(4===c)i(o,(function(r){r!==Q&&(void 0!==e[r]||u(e,r)?f[r]||n(o[r]):(f[r]=true,k(t)));})),i(e,(function(n){ void 0!==o[n]||u(o,n)||(f[n]=false,k(t));}));else if(5===c){if(a(t)&&(k(t),f.length=true),o.length<e.length)for(var s=o.length;s<e.length;s++)f[s]=false;else for(var v=e.length;v<o.length;v++)f[v]=true;for(var p=Math.min(o.length,e.length),l=0;l<p;l++)o.hasOwnProperty(l)||(f[l]=true),void 0===f[l]&&n(o[l]);}}}}(n.p[0]),e(n.p));},K:function(n){return 4===n.i?o(n):a(n)}});}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=true,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),true;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=false,true;if(c(t,i)&&(void 0!==t||u(n.t,r)))return true;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=true),true},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=false,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],true},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:true,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on$1={};i(en,(function(n,r){on$1[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on$1.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on$1.set.call(this,r,t,void 0)},on$1.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=true,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=true;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,true),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=true,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
|
|
1218
|
+
function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return false;var r=Object.getPrototypeOf(n);if(null===r)return true;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){ void 0===t&&(t=false),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];false===o.writable&&(o.writable=true,o.configurable=true),(o.get||o.set)&&(r[i]={configurable:true,writable:true,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=false),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,true)}),true)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function m(n,r){tn[n]||(tn[n]=r);}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:true,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=true;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),true),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,true),e.t;if(!e.I){e.I=true,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=false;3===e.i&&(u=new Set(o),o.clear(),a=true),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,false),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=false;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){ void 0===t&&(t=false),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=true,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:false,I:false,R:{},l:r,t:n,k:null,o:null,j:null,C:false},i=e,o=en;t&&(i=[e],o=on$1);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=true,e=D(r,c),u.I=false;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function F(){function t(n,r){var t=s[n];return t?t.enumerable=r:s[n]=t={configurable:true,enumerable:r,get:function(){var r=undefined[Q];return "production"!==process.env.NODE_ENV&&f(r),en.get(r,n)},set:function(r){var t=undefined[Q];"production"!==process.env.NODE_ENV&&f(t),en.set(t,n,r);}},t}function e(n){for(var r=n.length-1;r>=0;r--){var t=n[r][Q];if(!t.P)switch(t.i){case 5:a(t)&&k(t);break;case 4:o(t)&&k(t);}}}function o(n){for(var r=n.t,t=n.k,e=nn(t),i=e.length-1;i>=0;i--){var o=e[i];if(o!==Q){var a=r[o];if(void 0===a&&!u(r,o))return true;var f=t[o],s=f&&f[Q];if(s?s.t!==a:!c(f,a))return true}}var v=!!r[Q];return e.length!==nn(r).length+(v?0:1)}function a(n){var r=n.k;if(r.length!==n.t.length)return true;var t=Object.getOwnPropertyDescriptor(r,r.length-1);if(t&&!t.get)return true;for(var e=0;e<r.length;e++)if(!r.hasOwnProperty(e))return true;return false}function f(r){r.g&&n(3,JSON.stringify(p(r)));}var s={};m("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,true));return e}var o=rn(r);delete o[Q];for(var u=nn(o),a=0;a<u.length;a++){var f=u[a];o[f]=t(f,n||!!o[f].enumerable);}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:_(),P:false,I:false,R:{},l:r,t:n,k:i,o:null,g:false,C:false};return Object.defineProperty(i,Q,{value:o,writable:true}),i},S:function(n,t,o){o?r(t)&&t[Q].A===n&&e(n.p):(n.u&&function n(r){if(r&&"object"==typeof r){var t=r[Q];if(t){var e=t.t,o=t.k,f=t.R,c=t.i;if(4===c)i(o,(function(r){r!==Q&&(void 0!==e[r]||u(e,r)?f[r]||n(o[r]):(f[r]=true,k(t)));})),i(e,(function(n){ void 0!==o[n]||u(o,n)||(f[n]=false,k(t));}));else if(5===c){if(a(t)&&(k(t),f.length=true),o.length<e.length)for(var s=o.length;s<e.length;s++)f[s]=false;else for(var v=e.length;v<o.length;v++)f[v]=true;for(var p=Math.min(o.length,e.length),l=0;l<p;l++)o.hasOwnProperty(l)||(f[l]=true),void 0===f[l]&&n(o[l]);}}}}(n.p[0]),e(n.p));},K:function(n){return 4===n.i?o(n):a(n)}});}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=true,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),true;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=false,true;if(c(t,i)&&(void 0!==t||u(n.t,r)))return true;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=true),true},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=false,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],true},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:true,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on$1={};i(en,(function(n,r){on$1[n]=function(){return arguments[0]=arguments[0][0],r.apply(undefined,arguments)};})),on$1.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on$1.set.call(undefined,r,t,void 0)},on$1.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(undefined,r[0],t,e,r[0])};var un=function(){function e(r){var e=undefined;this.O=B,this.D=true,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=undefined;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=true;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D,o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(undefined),o=N(undefined,e,void 0);return o[Q].C=true,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
|
|
1221
1219
|
|
|
1222
|
-
var __extends = (
|
|
1220
|
+
var __extends = (function () {
|
|
1223
1221
|
var extendStatics = function (d, b) {
|
|
1224
1222
|
extendStatics = Object.setPrototypeOf ||
|
|
1225
1223
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
@@ -1234,9 +1232,9 @@ var __extends = (undefined && undefined.__extends) || (function () {
|
|
|
1234
1232
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1235
1233
|
};
|
|
1236
1234
|
})();
|
|
1237
|
-
var __generator =
|
|
1235
|
+
var __generator = function (thisArg, body) {
|
|
1238
1236
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1239
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return
|
|
1237
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return undefined; }), g;
|
|
1240
1238
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1241
1239
|
function step(op) {
|
|
1242
1240
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -1261,7 +1259,7 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
|
|
|
1261
1259
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1262
1260
|
}
|
|
1263
1261
|
};
|
|
1264
|
-
var __spreadArray =
|
|
1262
|
+
var __spreadArray = function (to, from) {
|
|
1265
1263
|
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
1266
1264
|
to[j] = from[i];
|
|
1267
1265
|
return to;
|
|
@@ -1339,7 +1337,7 @@ function createAction(type, prepareAction) {
|
|
|
1339
1337
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1340
1338
|
args[_i] = arguments[_i];
|
|
1341
1339
|
}
|
|
1342
|
-
var _this = _super.apply(
|
|
1340
|
+
var _this = _super.apply(undefined, args) || undefined;
|
|
1343
1341
|
Object.setPrototypeOf(_this, MiddlewareArray.prototype);
|
|
1344
1342
|
return _this;
|
|
1345
1343
|
}
|
|
@@ -1355,7 +1353,7 @@ function createAction(type, prepareAction) {
|
|
|
1355
1353
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1356
1354
|
arr[_i] = arguments[_i];
|
|
1357
1355
|
}
|
|
1358
|
-
return _super.prototype.concat.apply(
|
|
1356
|
+
return _super.prototype.concat.apply(undefined, arr);
|
|
1359
1357
|
};
|
|
1360
1358
|
MiddlewareArray.prototype.prepend = function () {
|
|
1361
1359
|
var arr = [];
|
|
@@ -1363,9 +1361,9 @@ function createAction(type, prepareAction) {
|
|
|
1363
1361
|
arr[_i] = arguments[_i];
|
|
1364
1362
|
}
|
|
1365
1363
|
if (arr.length === 1 && Array.isArray(arr[0])) {
|
|
1366
|
-
return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(
|
|
1364
|
+
return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(undefined))))();
|
|
1367
1365
|
}
|
|
1368
|
-
return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(
|
|
1366
|
+
return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(undefined))))();
|
|
1369
1367
|
};
|
|
1370
1368
|
return MiddlewareArray;
|
|
1371
1369
|
})(Array));
|
|
@@ -1376,7 +1374,7 @@ function createAction(type, prepareAction) {
|
|
|
1376
1374
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1377
1375
|
args[_i] = arguments[_i];
|
|
1378
1376
|
}
|
|
1379
|
-
var _this = _super.apply(
|
|
1377
|
+
var _this = _super.apply(undefined, args) || undefined;
|
|
1380
1378
|
Object.setPrototypeOf(_this, EnhancerArray.prototype);
|
|
1381
1379
|
return _this;
|
|
1382
1380
|
}
|
|
@@ -1392,7 +1390,7 @@ function createAction(type, prepareAction) {
|
|
|
1392
1390
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1393
1391
|
arr[_i] = arguments[_i];
|
|
1394
1392
|
}
|
|
1395
|
-
return _super.prototype.concat.apply(
|
|
1393
|
+
return _super.prototype.concat.apply(undefined, arr);
|
|
1396
1394
|
};
|
|
1397
1395
|
EnhancerArray.prototype.prepend = function () {
|
|
1398
1396
|
var arr = [];
|
|
@@ -1400,9 +1398,9 @@ function createAction(type, prepareAction) {
|
|
|
1400
1398
|
arr[_i] = arguments[_i];
|
|
1401
1399
|
}
|
|
1402
1400
|
if (arr.length === 1 && Array.isArray(arr[0])) {
|
|
1403
|
-
return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(
|
|
1401
|
+
return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr[0].concat(undefined))))();
|
|
1404
1402
|
}
|
|
1405
|
-
return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(
|
|
1403
|
+
return new (EnhancerArray.bind.apply(EnhancerArray, __spreadArray([void 0], arr.concat(undefined))))();
|
|
1406
1404
|
};
|
|
1407
1405
|
return EnhancerArray;
|
|
1408
1406
|
})(Array));
|
|
@@ -1723,9 +1721,9 @@ var miniSerializeError = function (value) {
|
|
|
1723
1721
|
abortController.abort();
|
|
1724
1722
|
}
|
|
1725
1723
|
var promise2 = function () {
|
|
1726
|
-
return __async(
|
|
1724
|
+
return __async(undefined, null, function () {
|
|
1727
1725
|
var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
|
|
1728
|
-
return __generator(
|
|
1726
|
+
return __generator(undefined, function (_c) {
|
|
1729
1727
|
switch (_c.label) {
|
|
1730
1728
|
case 0:
|
|
1731
1729
|
_c.trys.push([0, 4, , 5]);
|
|
@@ -1832,10 +1830,12 @@ typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "un
|
|
|
1832
1830
|
// src/index.ts
|
|
1833
1831
|
F();
|
|
1834
1832
|
|
|
1833
|
+
// src/redux/achievementSlice.ts
|
|
1835
1834
|
const initialState$1 = {
|
|
1836
1835
|
config: {},
|
|
1837
1836
|
metrics: {},
|
|
1838
1837
|
unlockedAchievements: [],
|
|
1838
|
+
previouslyAwardedAchievements: [], // Initialize as empty
|
|
1839
1839
|
storageKey: null,
|
|
1840
1840
|
};
|
|
1841
1841
|
const achievementSlice = createSlice({
|
|
@@ -1843,51 +1843,67 @@ const achievementSlice = createSlice({
|
|
|
1843
1843
|
initialState: initialState$1,
|
|
1844
1844
|
reducers: {
|
|
1845
1845
|
initialize: (state, action) => {
|
|
1846
|
-
var _a, _b;
|
|
1846
|
+
var _a, _b, _c, _d;
|
|
1847
1847
|
state.config = action.payload.config;
|
|
1848
1848
|
state.storageKey = action.payload.storageKey;
|
|
1849
1849
|
const storedState = action.payload.storageKey ? localStorage.getItem(action.payload.storageKey) : null;
|
|
1850
|
+
const initialMetrics = action.payload.initialState ? Object.keys(action.payload.initialState)
|
|
1851
|
+
.filter(key => key !== 'previouslyAwardedAchievements')
|
|
1852
|
+
.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: Array.isArray(action.payload.initialState[key]) ? action.payload.initialState[key] : [action.payload.initialState[key]] })), {}) : {};
|
|
1853
|
+
const initialAwarded = ((_a = action.payload.initialState) === null || _a === void 0 ? void 0 : _a.previouslyAwardedAchievements) || [];
|
|
1850
1854
|
if (storedState) {
|
|
1851
1855
|
try {
|
|
1852
1856
|
const parsedState = JSON.parse(storedState);
|
|
1853
|
-
state.metrics = ((
|
|
1854
|
-
state.unlockedAchievements = ((
|
|
1857
|
+
state.metrics = ((_b = parsedState.achievements) === null || _b === void 0 ? void 0 : _b.metrics) || initialMetrics;
|
|
1858
|
+
state.unlockedAchievements = ((_c = parsedState.achievements) === null || _c === void 0 ? void 0 : _c.unlockedAchievements) || [];
|
|
1859
|
+
state.previouslyAwardedAchievements = ((_d = parsedState.achievements) === null || _d === void 0 ? void 0 : _d.previouslyAwardedAchievements) || initialAwarded; // Prioritize stored, fallback to initial
|
|
1855
1860
|
}
|
|
1856
1861
|
catch (error) {
|
|
1857
1862
|
console.error('Error parsing stored achievement state:', error);
|
|
1858
|
-
state.metrics =
|
|
1863
|
+
state.metrics = initialMetrics;
|
|
1859
1864
|
state.unlockedAchievements = [];
|
|
1865
|
+
state.previouslyAwardedAchievements = initialAwarded;
|
|
1860
1866
|
}
|
|
1861
1867
|
}
|
|
1862
1868
|
else {
|
|
1863
|
-
state.metrics =
|
|
1869
|
+
state.metrics = initialMetrics;
|
|
1864
1870
|
state.unlockedAchievements = [];
|
|
1871
|
+
state.previouslyAwardedAchievements = initialAwarded;
|
|
1865
1872
|
}
|
|
1866
1873
|
},
|
|
1867
1874
|
setMetrics: (state, action) => {
|
|
1868
1875
|
state.metrics = action.payload;
|
|
1869
1876
|
if (state.storageKey) {
|
|
1870
|
-
localStorage.setItem(state.storageKey, JSON.stringify({ achievements: { metrics: state.metrics, unlockedAchievements: state.unlockedAchievements } }));
|
|
1877
|
+
localStorage.setItem(state.storageKey, JSON.stringify({ achievements: { metrics: state.metrics, unlockedAchievements: state.unlockedAchievements, previouslyAwardedAchievements: state.previouslyAwardedAchievements } }));
|
|
1871
1878
|
}
|
|
1872
1879
|
},
|
|
1873
1880
|
unlockAchievement: (state, action) => {
|
|
1874
1881
|
if (!state.unlockedAchievements.includes(action.payload)) {
|
|
1875
1882
|
state.unlockedAchievements.push(action.payload);
|
|
1876
1883
|
if (state.storageKey) {
|
|
1877
|
-
localStorage.setItem(state.storageKey, JSON.stringify({ achievements: { metrics: state.metrics, unlockedAchievements: state.unlockedAchievements } }));
|
|
1884
|
+
localStorage.setItem(state.storageKey, JSON.stringify({ achievements: { metrics: state.metrics, unlockedAchievements: state.unlockedAchievements, previouslyAwardedAchievements: state.previouslyAwardedAchievements } }));
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
},
|
|
1888
|
+
markAchievementAsAwarded: (state, action) => {
|
|
1889
|
+
if (!state.previouslyAwardedAchievements.includes(action.payload)) {
|
|
1890
|
+
state.previouslyAwardedAchievements.push(action.payload);
|
|
1891
|
+
if (state.storageKey) {
|
|
1892
|
+
localStorage.setItem(state.storageKey, JSON.stringify({ achievements: { metrics: state.metrics, unlockedAchievements: state.unlockedAchievements, previouslyAwardedAchievements: state.previouslyAwardedAchievements } }));
|
|
1878
1893
|
}
|
|
1879
1894
|
}
|
|
1880
1895
|
},
|
|
1881
1896
|
resetAchievements: (state) => {
|
|
1882
1897
|
state.metrics = {};
|
|
1883
1898
|
state.unlockedAchievements = [];
|
|
1899
|
+
state.previouslyAwardedAchievements = [];
|
|
1884
1900
|
if (state.storageKey) {
|
|
1885
1901
|
localStorage.removeItem(state.storageKey);
|
|
1886
1902
|
}
|
|
1887
1903
|
},
|
|
1888
1904
|
},
|
|
1889
1905
|
});
|
|
1890
|
-
const { initialize, setMetrics, unlockAchievement, resetAchievements } = achievementSlice.actions;
|
|
1906
|
+
const { initialize, setMetrics, unlockAchievement, resetAchievements, markAchievementAsAwarded } = achievementSlice.actions;
|
|
1891
1907
|
var achievementSlice$1 = achievementSlice.reducer;
|
|
1892
1908
|
|
|
1893
1909
|
const initialState = {
|
|
@@ -1908,117 +1924,6 @@ const notificationSlice = createSlice({
|
|
|
1908
1924
|
const { addNotification, clearNotifications } = notificationSlice.actions;
|
|
1909
1925
|
var notificationSlice$1 = notificationSlice.reducer;
|
|
1910
1926
|
|
|
1911
|
-
const defaultStyles = {
|
|
1912
|
-
achievementModal: {
|
|
1913
|
-
overlay: {
|
|
1914
|
-
position: 'fixed',
|
|
1915
|
-
top: 0,
|
|
1916
|
-
left: 0,
|
|
1917
|
-
right: 0,
|
|
1918
|
-
bottom: 0,
|
|
1919
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
1920
|
-
display: 'flex',
|
|
1921
|
-
alignItems: 'center',
|
|
1922
|
-
justifyContent: 'center',
|
|
1923
|
-
},
|
|
1924
|
-
content: {
|
|
1925
|
-
backgroundColor: '#ffffff',
|
|
1926
|
-
borderRadius: '8px',
|
|
1927
|
-
padding: '20px',
|
|
1928
|
-
maxWidth: '400px',
|
|
1929
|
-
width: '100%',
|
|
1930
|
-
},
|
|
1931
|
-
title: {
|
|
1932
|
-
fontSize: '24px',
|
|
1933
|
-
fontWeight: 'bold',
|
|
1934
|
-
marginBottom: '10px',
|
|
1935
|
-
},
|
|
1936
|
-
icon: {
|
|
1937
|
-
width: '50px',
|
|
1938
|
-
height: '50px',
|
|
1939
|
-
marginBottom: '10px',
|
|
1940
|
-
},
|
|
1941
|
-
description: {
|
|
1942
|
-
fontSize: '16px',
|
|
1943
|
-
marginBottom: '20px',
|
|
1944
|
-
},
|
|
1945
|
-
button: {
|
|
1946
|
-
backgroundColor: '#007bff',
|
|
1947
|
-
color: '#ffffff',
|
|
1948
|
-
padding: '10px 20px',
|
|
1949
|
-
borderRadius: '4px',
|
|
1950
|
-
border: 'none',
|
|
1951
|
-
cursor: 'pointer',
|
|
1952
|
-
},
|
|
1953
|
-
},
|
|
1954
|
-
badgesModal: {
|
|
1955
|
-
overlay: {
|
|
1956
|
-
position: 'fixed',
|
|
1957
|
-
top: 0,
|
|
1958
|
-
left: 0,
|
|
1959
|
-
right: 0,
|
|
1960
|
-
bottom: 0,
|
|
1961
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
1962
|
-
display: 'flex',
|
|
1963
|
-
alignItems: 'center',
|
|
1964
|
-
justifyContent: 'center',
|
|
1965
|
-
},
|
|
1966
|
-
content: {
|
|
1967
|
-
backgroundColor: '#ffffff',
|
|
1968
|
-
borderRadius: '8px',
|
|
1969
|
-
padding: '20px',
|
|
1970
|
-
maxWidth: '600px',
|
|
1971
|
-
width: '100%',
|
|
1972
|
-
maxHeight: '80vh',
|
|
1973
|
-
overflowY: 'auto',
|
|
1974
|
-
},
|
|
1975
|
-
title: {
|
|
1976
|
-
fontSize: '24px',
|
|
1977
|
-
fontWeight: 'bold',
|
|
1978
|
-
marginBottom: '20px',
|
|
1979
|
-
},
|
|
1980
|
-
badgeContainer: {
|
|
1981
|
-
display: 'flex',
|
|
1982
|
-
flexWrap: 'wrap',
|
|
1983
|
-
justifyContent: 'center',
|
|
1984
|
-
},
|
|
1985
|
-
badge: {
|
|
1986
|
-
display: 'flex',
|
|
1987
|
-
flexDirection: 'column',
|
|
1988
|
-
alignItems: 'center',
|
|
1989
|
-
margin: '10px',
|
|
1990
|
-
},
|
|
1991
|
-
badgeIcon: {
|
|
1992
|
-
width: '50px',
|
|
1993
|
-
height: '50px',
|
|
1994
|
-
marginBottom: '5px',
|
|
1995
|
-
},
|
|
1996
|
-
badgeTitle: {
|
|
1997
|
-
fontSize: '14px',
|
|
1998
|
-
textAlign: 'center',
|
|
1999
|
-
},
|
|
2000
|
-
button: {
|
|
2001
|
-
backgroundColor: '#007bff',
|
|
2002
|
-
color: '#ffffff',
|
|
2003
|
-
padding: '10px 20px',
|
|
2004
|
-
borderRadius: '4px',
|
|
2005
|
-
border: 'none',
|
|
2006
|
-
cursor: 'pointer',
|
|
2007
|
-
marginTop: '20px',
|
|
2008
|
-
},
|
|
2009
|
-
},
|
|
2010
|
-
badgesButton: {
|
|
2011
|
-
position: 'fixed',
|
|
2012
|
-
padding: '10px 20px',
|
|
2013
|
-
backgroundColor: '#007bff',
|
|
2014
|
-
color: '#ffffff',
|
|
2015
|
-
border: 'none',
|
|
2016
|
-
borderRadius: '4px',
|
|
2017
|
-
cursor: 'pointer',
|
|
2018
|
-
zIndex: 1000,
|
|
2019
|
-
},
|
|
2020
|
-
};
|
|
2021
|
-
|
|
2022
1927
|
// src/defaultIcons.ts
|
|
2023
1928
|
const defaultAchievementIcons = {
|
|
2024
1929
|
// General Progress & Milestones
|
|
@@ -2126,6 +2031,22 @@ const AchievementModal = ({ isOpen, achievement, onClose, styles, icons = {} })
|
|
|
2126
2031
|
};
|
|
2127
2032
|
var AchievementModal$1 = React.memo(AchievementModal);
|
|
2128
2033
|
|
|
2034
|
+
const BadgesButton = ({ onClick, position, styles, unlockedAchievements, icon, drawer = false, customStyles, }) => {
|
|
2035
|
+
const positionStyle = position
|
|
2036
|
+
? {
|
|
2037
|
+
[position.split('-')[0]]: '20px',
|
|
2038
|
+
[position.split('-')[1]]: '20px',
|
|
2039
|
+
}
|
|
2040
|
+
: {};
|
|
2041
|
+
const handleButtonClick = () => {
|
|
2042
|
+
onClick();
|
|
2043
|
+
};
|
|
2044
|
+
const achievementsText = 'View Achievements';
|
|
2045
|
+
const buttonContent = icon ? icon : achievementsText;
|
|
2046
|
+
return (React.createElement("button", { onClick: handleButtonClick, style: Object.assign(Object.assign(Object.assign({}, styles), positionStyle), customStyles) }, buttonContent));
|
|
2047
|
+
};
|
|
2048
|
+
var BadgesButton$1 = React.memo(BadgesButton);
|
|
2049
|
+
|
|
2129
2050
|
const BadgesModal = ({ isOpen, achievements, onClose, styles, icons = {} }) => {
|
|
2130
2051
|
if (!isOpen)
|
|
2131
2052
|
return null;
|
|
@@ -2147,26 +2068,10 @@ const BadgesModal = ({ isOpen, achievements, onClose, styles, icons = {} }) => {
|
|
|
2147
2068
|
};
|
|
2148
2069
|
var BadgesModal$1 = React.memo(BadgesModal);
|
|
2149
2070
|
|
|
2150
|
-
const BadgesButton = ({ onClick, position, styles, unlockedAchievements, icon, drawer = false, customStyles, }) => {
|
|
2151
|
-
const positionStyle = position
|
|
2152
|
-
? {
|
|
2153
|
-
[position.split('-')[0]]: '20px',
|
|
2154
|
-
[position.split('-')[1]]: '20px',
|
|
2155
|
-
}
|
|
2156
|
-
: {};
|
|
2157
|
-
const handleButtonClick = () => {
|
|
2158
|
-
onClick();
|
|
2159
|
-
};
|
|
2160
|
-
const achievementsText = 'View Achievements';
|
|
2161
|
-
const buttonContent = icon ? icon : achievementsText;
|
|
2162
|
-
return (React.createElement("button", { onClick: handleButtonClick, style: Object.assign(Object.assign(Object.assign({}, styles), positionStyle), customStyles) }, buttonContent));
|
|
2163
|
-
};
|
|
2164
|
-
var BadgesButton$1 = React.memo(BadgesButton);
|
|
2165
|
-
|
|
2166
2071
|
var reactConfetti_min = {exports: {}};
|
|
2167
2072
|
|
|
2168
2073
|
(function (module, exports) {
|
|
2169
|
-
!function(t,e){module.exports=e(React);}("undefined"!=typeof self?self:commonjsGlobal,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:false,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=true,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:true,get:r});},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:true});},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:true,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(e,n){e.exports=t;},function(t,e,n){var r={linear:function(t,e,n,r){return (n-e)*t/r+e},easeInQuad:function(t,e,n,r){return (n-e)*(t/=r)*t+e},easeOutQuad:function(t,e,n,r){return -(n-e)*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,n,r){return (n-e)*(t/=r)*t*t+e},easeOutCubic:function(t,e,n,r){return (n-e)*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,n,r){return (n-e)*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,n,r){return -(n-e)*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,n,r){return (n-e)*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,n,r){return (n-e)*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,n,r){var i=n-e;return -i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,n,r){return (n-e)*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,n,r){return -(n-e)/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,n,r){return 0==t?e:(n-e)*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,n,r){var i=n-e;return t==r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,n,r){var i=n-e;return 0===t?e:t===r?e+i:(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,n,r){return -(n-e)*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,n,r){return (n-e)*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,n,r){var i,o,a,c=n-e;return a=1.70158,0===t?e:1==(t/=r)?e+c:((o=0)||(o=.3*r),(i=c)<Math.abs(c)?(i=c,a=o/4):a=o/(2*Math.PI)*Math.asin(c/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+e)},easeOutElastic:function(t,e,n,r){var i,o,a,c=n-e;return a=1.70158,0===t?e:1==(t/=r)?e+c:((o=0)||(o=.3*r),(i=c)<Math.abs(c)?(i=c,a=o/4):a=o/(2*Math.PI)*Math.asin(c/i),i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+c+e)},easeInOutElastic:function(t,e,n,r){var i,o,a,c=n-e;return a=1.70158,0===t?e:2==(t/=r/2)?e+c:((o=0)||(o=r*(.3*1.5)),(i=c)<Math.abs(c)?(i=c,a=o/4):a=o/(2*Math.PI)*Math.asin(c/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-0.5+e:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+c+e)},easeInBack:function(t,e,n,r,i){return void 0===i&&(i=1.70158),(n-e)*(t/=r)*t*((i+1)*t-i)+e},easeOutBack:function(t,e,n,r,i){return void 0===i&&(i=1.70158),(n-e)*((t=t/r-1)*t*((i+1)*t+i)+1)+e},easeInOutBack:function(t,e,n,r,i){var o=n-e;return void 0===i&&(i=1.70158),(t/=r/2)<1?o/2*(t*t*((1+(i*=1.525))*t-i))+e:o/2*((t-=2)*t*((1+(i*=1.525))*t+i)+2)+e},easeInBounce:function(t,e,n,i){var o=n-e;return o-r.easeOutBounce(i-t,0,o,i)+e},easeOutBounce:function(t,e,n,r){var i=n-e;return (t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(t,e,n,i){var o=n-e;return t<i/2?.5*r.easeInBounce(2*t,0,o,i)+e:.5*r.easeOutBounce(2*t-i,0,o,i)+.5*o+e}};t.exports=r;},function(t,e,n){t.exports=n(3);},function(t,e,n){n.r(e),n.d(e,"ReactConfetti",(function(){return Q}));var r,i,o=n(0),a=n.n(o),c=n(1),s=n.n(c);function u(t,e){return t+Math.random()*(e-t)}function f(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false,r.configurable=true,"value"in r&&(r.writable=true),Object.defineProperty(t,r.key,r);}}function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Strip=2]="Strip";}(r||(r={})),function(t){t[t.Positive=1]="Positive",t[t.Negative=-1]="Negative";}(i||(i={}));var l=function(){function t(e,n,r,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),h(this,"context",void 0),h(this,"radius",void 0),h(this,"x",void 0),h(this,"y",void 0),h(this,"w",void 0),h(this,"h",void 0),h(this,"vx",void 0),h(this,"vy",void 0),h(this,"shape",void 0),h(this,"angle",void 0),h(this,"angularSpin",void 0),h(this,"color",void 0),h(this,"rotateY",void 0),h(this,"rotationDirection",void 0),h(this,"getOptions",void 0),this.getOptions=n;var a,c,s=this.getOptions(),f=s.colors,l=s.initialVelocityX,p=s.initialVelocityY;this.context=e,this.x=r,this.y=o,this.w=u(5,20),this.h=u(5,20),this.radius=u(5,10),this.vx="number"==typeof l?u(-l,l):u(l.min,l.max),this.vy="number"==typeof p?u(-p,0):u(p.min,p.max),this.shape=(a=0,c=2,Math.floor(a+Math.random()*(c-a+1))),this.angle=u(0,360)*Math.PI/180,this.angularSpin=u(-0.2,.2),this.color=f[Math.floor(Math.random()*f.length)],this.rotateY=u(0,1),this.rotationDirection=u(0,1)?i.Positive:i.Negative;}var e,n;return e=t,(n=[{key:"update",value:function(){var t=this.getOptions(),e=t.gravity,n=t.wind,o=t.friction,a=t.opacity,c=t.drawShape;this.x+=this.vx,this.y+=this.vy,this.vy+=e,this.vx+=n,this.vx*=o,this.vy*=o,this.rotateY>=1&&this.rotationDirection===i.Positive?this.rotationDirection=i.Negative:this.rotateY<=-1&&this.rotationDirection===i.Negative&&(this.rotationDirection=i.Positive);var s=.1*this.rotationDirection;if(this.rotateY+=s,this.angle+=this.angularSpin,this.context.save(),this.context.translate(this.x,this.y),this.context.rotate(this.angle),this.context.scale(1,this.rotateY),this.context.rotate(this.angle),this.context.beginPath(),this.context.fillStyle=this.color,this.context.strokeStyle=this.color,this.context.globalAlpha=a,this.context.lineCap="round",this.context.lineWidth=2,c&&"function"==typeof c)c.call(this,this.context);else switch(this.shape){case r.Circle:this.context.beginPath(),this.context.arc(0,0,this.radius,0,2*Math.PI),this.context.fill();break;case r.Square:this.context.fillRect(-this.w/2,-this.h/2,this.w,this.h);break;case r.Strip:this.context.fillRect(-this.w/6,-this.h/2,this.w/3,this.h);}this.context.closePath(),this.context.restore();}}])&&f(e.prototype,n),t}();function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}var v=function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),p(this,"canvas",void 0),p(this,"context",void 0),p(this,"getOptions",void 0),p(this,"x",0),p(this,"y",0),p(this,"w",0),p(this,"h",0),p(this,"lastNumberOfPieces",0),p(this,"tweenInitTime",Date.now()),p(this,"particles",[]),p(this,"particlesGenerated",0),p(this,"removeParticleAt",(function(t){r.particles.splice(t,1);})),p(this,"getParticle",(function(){var t=u(r.x,r.w+r.x),e=u(r.y,r.h+r.y);return new l(r.context,r.getOptions,t,e)})),p(this,"animate",(function(){var t=r.canvas,e=r.context,n=r.particlesGenerated,i=r.lastNumberOfPieces,o=r.getOptions(),a=o.run,c=o.recycle,s=o.numberOfPieces,u=o.debug,f=o.tweenFunction,h=o.tweenDuration;if(!a)return false;var l=r.particles.length,p=c?l:n,v=Date.now();if(p<s){i!==s&&(r.tweenInitTime=v,r.lastNumberOfPieces=s);for(var y=r.tweenInitTime,d=f(v-y>h?h:Math.max(0,v-y),p,s,h),b=Math.round(d-p),g=0;g<b;g++)r.particles.push(r.getParticle());r.particlesGenerated+=b;}return u&&(e.font="12px sans-serif",e.fillStyle="#333",e.textAlign="right",e.fillText("Particles: ".concat(l),t.width-10,t.height-20)),r.particles.forEach((function(e,n){e.update(),(e.y>t.height||e.y<-100||e.x>t.width+100||e.x<-100)&&(c&&p<=s?r.particles[n]=r.getParticle():r.removeParticleAt(n));})),l>0||p<s})),this.canvas=e;var i=this.canvas.getContext("2d");if(!i)throw new Error("Could not get canvas context");this.context=i,this.getOptions=n;};function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r);}return n}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),true).forEach((function(e){g(t,e,n[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));}));}return t}function b(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false,r.configurable=true,"value"in r&&(r.writable=true),Object.defineProperty(t,r.key,r);}}function g(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}var O={width:"undefined"!=typeof window?window.innerWidth:300,height:"undefined"!=typeof window?window.innerHeight:200,numberOfPieces:200,friction:.99,wind:0,gravity:.1,initialVelocityX:4,initialVelocityY:10,colors:["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],opacity:1,debug:false,tweenFunction:s.a.easeInOutQuad,tweenDuration:5e3,recycle:true,run:true},w=function(){function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),g(this,"canvas",void 0),g(this,"context",void 0),g(this,"_options",void 0),g(this,"generator",void 0),g(this,"rafId",void 0),g(this,"setOptionsWithDefaults",(function(t){var e={confettiSource:{x:0,y:0,w:r.canvas.width,h:0}};r._options=d(d(d({},e),O),t),Object.assign(r,t.confettiSource);})),g(this,"update",(function(){var t=r.options,e=t.run,n=t.onConfettiComplete,i=r.canvas,o=r.context;e&&(o.fillStyle="white",o.clearRect(0,0,i.width,i.height)),r.generator.animate()?r.rafId=requestAnimationFrame(r.update):(n&&"function"==typeof n&&r.generator.particlesGenerated>0&&n.call(r,r),r._options.run=false);})),g(this,"reset",(function(){r.generator&&r.generator.particlesGenerated>0&&(r.generator.particlesGenerated=0,r.generator.particles=[],r.generator.lastNumberOfPieces=0);})),g(this,"stop",(function(){r.options={run:false},r.rafId&&(cancelAnimationFrame(r.rafId),r.rafId=void 0);})),this.canvas=e;var i=this.canvas.getContext("2d");if(!i)throw new Error("Could not get canvas context");this.context=i,this.generator=new v(this.canvas,(function(){return r.options})),this.options=n,this.update();}var e,n;return e=t,(n=[{key:"options",get:function(){return this._options},set:function(t){var e=this._options&&this._options.run,n=this._options&&this._options.recycle;this.setOptionsWithDefaults(t),this.generator&&(Object.assign(this.generator,this.options.confettiSource),"boolean"==typeof t.recycle&&t.recycle&&false===n&&(this.generator.lastNumberOfPieces=this.generator.particles.length)),"boolean"==typeof t.run&&t.run&&false===e&&this.update();}}])&&b(e.prototype,n),t}();function m(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t){return (x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function P(){return (P=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);}return t}).apply(this,arguments)}function j(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r);}return n}function M(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?j(Object(n),true).forEach((function(e){T(t,e,n[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));}));}return t}function I(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=true,i=false,o=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=true,o=t;}finally{try{r||null==c.return||c.return();}finally{if(i)throw o}}return n}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return C(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(t,e):void 0}}function C(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function D(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function E(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false,r.configurable=true,"value"in r&&(r.writable=true),Object.defineProperty(t,r.key,r);}}function _(t,e){return (_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function R(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if("function"==typeof Proxy)return true;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return false}}();return function(){var n,r=F(t);if(e){var i=F(this).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(this,arguments);return k(this,n)}}function k(t,e){return !e||"object"!==x(e)&&"function"!=typeof e?A(t):e}function A(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function F(t){return (F=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function T(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}var B=a.a.createRef(),N=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}}),e&&_(t,e);}(o,t);var e,n,i=R(o);function o(t){var e;D(this,o);for(var n=arguments.length,r=new Array(n>1?n-1:0),c=1;c<n;c++)r[c-1]=arguments[c];return T(A(e=i.call.apply(i,[this,t].concat(r))),"canvas",a.a.createRef()),T(A(e),"confetti",void 0),e.canvas=t.canvasRef||B,e}return e=o,(n=[{key:"componentDidMount",value:function(){if(this.canvas.current){var t=q(this.props)[0];this.confetti=new w(this.canvas.current,t);}}},{key:"componentDidUpdate",value:function(){var t=q(this.props)[0];this.confetti&&(this.confetti.options=t);}},{key:"componentWillUnmount",value:function(){this.confetti&&this.confetti.stop(),this.confetti=void 0;}},{key:"render",value:function(){var t=I(q(this.props),2),e=t[0],n=t[1],r=M({zIndex:2,position:"absolute",pointerEvents:"none",top:0,left:0,bottom:0,right:0},n.style);return a.a.createElement("canvas",P({width:e.width,height:e.height,ref:this.canvas},n,{style:r}))}}])&&E(e.prototype,n),o}(o.Component);function q(t){var e={},n={},r=[].concat(m(Object.keys(O)),["confettiSource","drawShape","onConfettiComplete"]),i=["canvasRef"];for(var o in t){var a=t[o];r.includes(o)?e[o]=a:i.includes(o)?i[o]=a:n[o]=a;}return [e,n,{}]}T(N,"defaultProps",M({},O)),T(N,"displayName","ReactConfetti");var Q=a.a.forwardRef((function(t,e){return a.a.createElement(N,P({canvasRef:e},t))}));e.default=Q;}]).default}));
|
|
2074
|
+
!function(t,e){module.exports=e(React);}("undefined"!=typeof self?self:undefined,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:false,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=true,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:true,get:r});},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:true});},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:true,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(e,n){e.exports=t;},function(t,e,n){var r={linear:function(t,e,n,r){return (n-e)*t/r+e},easeInQuad:function(t,e,n,r){return (n-e)*(t/=r)*t+e},easeOutQuad:function(t,e,n,r){return -(n-e)*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,n,r){return (n-e)*(t/=r)*t*t+e},easeOutCubic:function(t,e,n,r){return (n-e)*((t=t/r-1)*t*t+1)+e},easeInOutCubic:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t*t+e:i/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,n,r){return (n-e)*(t/=r)*t*t*t+e},easeOutQuart:function(t,e,n,r){return -(n-e)*((t=t/r-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t*t*t+e:-i/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,n,r){return (n-e)*(t/=r)*t*t*t*t+e},easeOutQuint:function(t,e,n,r){return (n-e)*((t=t/r-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,n,r){var i=n-e;return -i*Math.cos(t/r*(Math.PI/2))+i+e},easeOutSine:function(t,e,n,r){return (n-e)*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,n,r){return -(n-e)/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,n,r){return 0==t?e:(n-e)*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,n,r){var i=n-e;return t==r?e+i:i*(1-Math.pow(2,-10*t/r))+e},easeInOutExpo:function(t,e,n,r){var i=n-e;return 0===t?e:t===r?e+i:(t/=r/2)<1?i/2*Math.pow(2,10*(t-1))+e:i/2*(2-Math.pow(2,-10*--t))+e},easeInCirc:function(t,e,n,r){return -(n-e)*(Math.sqrt(1-(t/=r)*t)-1)+e},easeOutCirc:function(t,e,n,r){return (n-e)*Math.sqrt(1-(t=t/r-1)*t)+e},easeInOutCirc:function(t,e,n,r){var i=n-e;return (t/=r/2)<1?-i/2*(Math.sqrt(1-t*t)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,n,r){var i,o,a,c=n-e;return a=1.70158,0===t?e:1==(t/=r)?e+c:((o=0)||(o=.3*r),(i=c)<Math.abs(c)?(i=c,a=o/4):a=o/(2*Math.PI)*Math.asin(c/i),-i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)+e)},easeOutElastic:function(t,e,n,r){var i,o,a,c=n-e;return a=1.70158,0===t?e:1==(t/=r)?e+c:((o=0)||(o=.3*r),(i=c)<Math.abs(c)?(i=c,a=o/4):a=o/(2*Math.PI)*Math.asin(c/i),i*Math.pow(2,-10*t)*Math.sin((t*r-a)*(2*Math.PI)/o)+c+e)},easeInOutElastic:function(t,e,n,r){var i,o,a,c=n-e;return a=1.70158,0===t?e:2==(t/=r/2)?e+c:((o=0)||(o=r*(.3*1.5)),(i=c)<Math.abs(c)?(i=c,a=o/4):a=o/(2*Math.PI)*Math.asin(c/i),t<1?i*Math.pow(2,10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*-0.5+e:i*Math.pow(2,-10*(t-=1))*Math.sin((t*r-a)*(2*Math.PI)/o)*.5+c+e)},easeInBack:function(t,e,n,r,i){return void 0===i&&(i=1.70158),(n-e)*(t/=r)*t*((i+1)*t-i)+e},easeOutBack:function(t,e,n,r,i){return void 0===i&&(i=1.70158),(n-e)*((t=t/r-1)*t*((i+1)*t+i)+1)+e},easeInOutBack:function(t,e,n,r,i){var o=n-e;return void 0===i&&(i=1.70158),(t/=r/2)<1?o/2*(t*t*((1+(i*=1.525))*t-i))+e:o/2*((t-=2)*t*((1+(i*=1.525))*t+i)+2)+e},easeInBounce:function(t,e,n,i){var o=n-e;return o-r.easeOutBounce(i-t,0,o,i)+e},easeOutBounce:function(t,e,n,r){var i=n-e;return (t/=r)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(t,e,n,i){var o=n-e;return t<i/2?.5*r.easeInBounce(2*t,0,o,i)+e:.5*r.easeOutBounce(2*t-i,0,o,i)+.5*o+e}};t.exports=r;},function(t,e,n){t.exports=n(3);},function(t,e,n){n.r(e),n.d(e,"ReactConfetti",(function(){return Q}));var r,i,o=n(0),a=n.n(o),c=n(1),s=n.n(c);function u(t,e){return t+Math.random()*(e-t)}function f(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false,r.configurable=true,"value"in r&&(r.writable=true),Object.defineProperty(t,r.key,r);}}function h(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}!function(t){t[t.Circle=0]="Circle",t[t.Square=1]="Square",t[t.Strip=2]="Strip";}(r||(r={})),function(t){t[t.Positive=1]="Positive",t[t.Negative=-1]="Negative";}(i||(i={}));var l=function(){function t(e,n,r,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(undefined,t),h(undefined,"context",void 0),h(undefined,"radius",void 0),h(undefined,"x",void 0),h(undefined,"y",void 0),h(undefined,"w",void 0),h(undefined,"h",void 0),h(undefined,"vx",void 0),h(undefined,"vy",void 0),h(undefined,"shape",void 0),h(undefined,"angle",void 0),h(undefined,"angularSpin",void 0),h(undefined,"color",void 0),h(undefined,"rotateY",void 0),h(undefined,"rotationDirection",void 0),h(undefined,"getOptions",void 0),this.getOptions=n;var a,c,s=this.getOptions(),f=s.colors,l=s.initialVelocityX,p=s.initialVelocityY;this.context=e,this.x=r,this.y=o,this.w=u(5,20),this.h=u(5,20),this.radius=u(5,10),this.vx="number"==typeof l?u(-l,l):u(l.min,l.max),this.vy="number"==typeof p?u(-p,0):u(p.min,p.max),this.shape=(a=0,c=2,Math.floor(a+Math.random()*(c-a+1))),this.angle=u(0,360)*Math.PI/180,this.angularSpin=u(-0.2,.2),this.color=f[Math.floor(Math.random()*f.length)],this.rotateY=u(0,1),this.rotationDirection=u(0,1)?i.Positive:i.Negative;}var e,n;return e=t,(n=[{key:"update",value:function(){var t=this.getOptions(),e=t.gravity,n=t.wind,o=t.friction,a=t.opacity,c=t.drawShape;this.x+=this.vx,this.y+=this.vy,this.vy+=e,this.vx+=n,this.vx*=o,this.vy*=o,this.rotateY>=1&&this.rotationDirection===i.Positive?this.rotationDirection=i.Negative:this.rotateY<=-1&&this.rotationDirection===i.Negative&&(this.rotationDirection=i.Positive);var s=.1*this.rotationDirection;if(this.rotateY+=s,this.angle+=this.angularSpin,this.context.save(),this.context.translate(this.x,this.y),this.context.rotate(this.angle),this.context.scale(1,this.rotateY),this.context.rotate(this.angle),this.context.beginPath(),this.context.fillStyle=this.color,this.context.strokeStyle=this.color,this.context.globalAlpha=a,this.context.lineCap="round",this.context.lineWidth=2,c&&"function"==typeof c)c.call(undefined,this.context);else switch(this.shape){case r.Circle:this.context.beginPath(),this.context.arc(0,0,this.radius,0,2*Math.PI),this.context.fill();break;case r.Square:this.context.fillRect(-this.w/2,-this.h/2,this.w,this.h);break;case r.Strip:this.context.fillRect(-this.w/6,-this.h/2,this.w/3,this.h);}this.context.closePath(),this.context.restore();}}])&&f(e.prototype,n),t}();function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}var v=function t(e,n){var r=undefined;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(undefined,t),p(undefined,"canvas",void 0),p(undefined,"context",void 0),p(undefined,"getOptions",void 0),p(undefined,"x",0),p(undefined,"y",0),p(undefined,"w",0),p(undefined,"h",0),p(undefined,"lastNumberOfPieces",0),p(undefined,"tweenInitTime",Date.now()),p(undefined,"particles",[]),p(undefined,"particlesGenerated",0),p(undefined,"removeParticleAt",(function(t){r.particles.splice(t,1);})),p(undefined,"getParticle",(function(){var t=u(r.x,r.w+r.x),e=u(r.y,r.h+r.y);return new l(r.context,r.getOptions,t,e)})),p(undefined,"animate",(function(){var t=r.canvas,e=r.context,n=r.particlesGenerated,i=r.lastNumberOfPieces,o=r.getOptions(),a=o.run,c=o.recycle,s=o.numberOfPieces,u=o.debug,f=o.tweenFunction,h=o.tweenDuration;if(!a)return false;var l=r.particles.length,p=c?l:n,v=Date.now();if(p<s){i!==s&&(r.tweenInitTime=v,r.lastNumberOfPieces=s);for(var y=r.tweenInitTime,d=f(v-y>h?h:Math.max(0,v-y),p,s,h),b=Math.round(d-p),g=0;g<b;g++)r.particles.push(r.getParticle());r.particlesGenerated+=b;}return u&&(e.font="12px sans-serif",e.fillStyle="#333",e.textAlign="right",e.fillText("Particles: ".concat(l),t.width-10,t.height-20)),r.particles.forEach((function(e,n){e.update(),(e.y>t.height||e.y<-100||e.x>t.width+100||e.x<-100)&&(c&&p<=s?r.particles[n]=r.getParticle():r.removeParticleAt(n));})),l>0||p<s})),this.canvas=e;var i=this.canvas.getContext("2d");if(!i)throw new Error("Could not get canvas context");this.context=i,this.getOptions=n;};function y(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r);}return n}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?y(Object(n),true).forEach((function(e){g(t,e,n[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));}));}return t}function b(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false,r.configurable=true,"value"in r&&(r.writable=true),Object.defineProperty(t,r.key,r);}}function g(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}var O={width:"undefined"!=typeof window?window.innerWidth:300,height:"undefined"!=typeof window?window.innerHeight:200,numberOfPieces:200,friction:.99,wind:0,gravity:.1,initialVelocityX:4,initialVelocityY:10,colors:["#f44336","#e91e63","#9c27b0","#673ab7","#3f51b5","#2196f3","#03a9f4","#00bcd4","#009688","#4CAF50","#8BC34A","#CDDC39","#FFEB3B","#FFC107","#FF9800","#FF5722","#795548"],opacity:1,debug:false,tweenFunction:s.a.easeInOutQuad,tweenDuration:5e3,recycle:true,run:true},w=function(){function t(e,n){var r=undefined;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(undefined,t),g(undefined,"canvas",void 0),g(undefined,"context",void 0),g(undefined,"_options",void 0),g(undefined,"generator",void 0),g(undefined,"rafId",void 0),g(undefined,"setOptionsWithDefaults",(function(t){var e={confettiSource:{x:0,y:0,w:r.canvas.width,h:0}};r._options=d(d(d({},e),O),t),Object.assign(r,t.confettiSource);})),g(undefined,"update",(function(){var t=r.options;t.run;t.onConfettiComplete;r.canvas;r.context;r.generator.animate()?r.rafId=requestAnimationFrame(r.update):(r._options.run=false);})),g(undefined,"reset",(function(){r.generator;})),g(undefined,"stop",(function(){r.options={run:false},r.rafId;})),this.canvas=e;var i=this.canvas.getContext("2d");if(!i)throw new Error("Could not get canvas context");this.context=i,this.generator=new v(this.canvas,(function(){return r.options})),this.options=n,this.update();}var e,n;return e=t,(n=[{key:"options",get:function(){return this._options},set:function(t){var e=this._options&&this._options.run,n=this._options&&this._options.recycle;this.setOptionsWithDefaults(t),this.generator&&(Object.assign(this.generator,this.options.confettiSource),"boolean"==typeof t.recycle&&t.recycle&&false===n&&(this.generator.lastNumberOfPieces=this.generator.particles.length)),"boolean"==typeof t.run&&t.run&&false===e&&this.update();}}])&&b(e.prototype,n),t}();function m(t){return function(t){if(Array.isArray(t))return C(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t){return (x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function P(){return (P=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);}return t}).apply(undefined,arguments)}function j(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r);}return n}function M(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?j(Object(n),true).forEach((function(e){T(t,e,n[e]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));}));}return t}function I(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],r=true,i=false,o=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=true,o=t;}finally{try{r||null==c.return||c.return();}finally{if(i)throw o}}return n}(t,e)||S(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(t,e){if(t){if("string"==typeof t)return C(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(t,e):void 0}}function C(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function D(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function E(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||false,r.configurable=true,"value"in r&&(r.writable=true),Object.defineProperty(t,r.key,r);}}function _(t,e){return (_=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function R(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if("function"==typeof Proxy)return true;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return false}}();return function(){var n,r=F(t);if(e){var i=F(undefined).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(undefined,arguments);return k(undefined,n)}}function k(t,e){return !e||"object"!==x(e)&&"function"!=typeof e?A(t):e}function A(t){if(void 0===t)throw new ReferenceError("undefined hasn't been initialised - super() hasn't been called");return t}function F(t){return (F=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function T(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:true,configurable:true,writable:true}):t[e]=n,t}var B=a.a.createRef(),N=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:true,configurable:true}}),e&&_(t,e);}(o,t);var e,n,i=R(o);function o(t){var e;D(undefined,o);for(var n=arguments.length,r=new Array(n>1?n-1:0),c=1;c<n;c++)r[c-1]=arguments[c];return T(A(e=i.call.apply(i,[undefined,t].concat(r))),"canvas",a.a.createRef()),T(A(e),"confetti",void 0),e.canvas=t.canvasRef||B,e}return e=o,(n=[{key:"componentDidMount",value:function(){if(this.canvas.current){var t=q(this.props)[0];this.confetti=new w(this.canvas.current,t);}}},{key:"componentDidUpdate",value:function(){var t=q(this.props)[0];this.confetti&&(this.confetti.options=t);}},{key:"componentWillUnmount",value:function(){this.confetti&&this.confetti.stop(),this.confetti=void 0;}},{key:"render",value:function(){var t=I(q(this.props),2),e=t[0],n=t[1],r=M({zIndex:2,position:"absolute",pointerEvents:"none",top:0,left:0,bottom:0,right:0},n.style);return a.a.createElement("canvas",P({width:e.width,height:e.height,ref:this.canvas},n,{style:r}))}}])&&E(e.prototype,n),o}(o.Component);function q(t){var e={},n={},r=[].concat(m(Object.keys(O)),["confettiSource","drawShape","onConfettiComplete"]),i=["canvasRef"];for(var o in t){var a=t[o];r.includes(o)?e[o]=a:i.includes(o)?i[o]=a:n[o]=a;}return [e,n,{}]}T(N,"defaultProps",M({},O)),T(N,"displayName","ReactConfetti");var Q=a.a.forwardRef((function(t,e){return a.a.createElement(N,P({canvasRef:e},t))}));e.default=Q;}]).default}));
|
|
2170
2075
|
|
|
2171
2076
|
} (reactConfetti_min));
|
|
2172
2077
|
|
|
@@ -2250,6 +2155,117 @@ const ConfettiWrapper = ({ show }) => {
|
|
|
2250
2155
|
return React.createElement(Confetti, { width: width, height: height, recycle: false });
|
|
2251
2156
|
};
|
|
2252
2157
|
|
|
2158
|
+
const defaultStyles = {
|
|
2159
|
+
achievementModal: {
|
|
2160
|
+
overlay: {
|
|
2161
|
+
position: 'fixed',
|
|
2162
|
+
top: 0,
|
|
2163
|
+
left: 0,
|
|
2164
|
+
right: 0,
|
|
2165
|
+
bottom: 0,
|
|
2166
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
2167
|
+
display: 'flex',
|
|
2168
|
+
alignItems: 'center',
|
|
2169
|
+
justifyContent: 'center',
|
|
2170
|
+
},
|
|
2171
|
+
content: {
|
|
2172
|
+
backgroundColor: '#ffffff',
|
|
2173
|
+
borderRadius: '8px',
|
|
2174
|
+
padding: '20px',
|
|
2175
|
+
maxWidth: '400px',
|
|
2176
|
+
width: '100%',
|
|
2177
|
+
},
|
|
2178
|
+
title: {
|
|
2179
|
+
fontSize: '24px',
|
|
2180
|
+
fontWeight: 'bold',
|
|
2181
|
+
marginBottom: '10px',
|
|
2182
|
+
},
|
|
2183
|
+
icon: {
|
|
2184
|
+
width: '50px',
|
|
2185
|
+
height: '50px',
|
|
2186
|
+
marginBottom: '10px',
|
|
2187
|
+
},
|
|
2188
|
+
description: {
|
|
2189
|
+
fontSize: '16px',
|
|
2190
|
+
marginBottom: '20px',
|
|
2191
|
+
},
|
|
2192
|
+
button: {
|
|
2193
|
+
backgroundColor: '#007bff',
|
|
2194
|
+
color: '#ffffff',
|
|
2195
|
+
padding: '10px 20px',
|
|
2196
|
+
borderRadius: '4px',
|
|
2197
|
+
border: 'none',
|
|
2198
|
+
cursor: 'pointer',
|
|
2199
|
+
},
|
|
2200
|
+
},
|
|
2201
|
+
badgesModal: {
|
|
2202
|
+
overlay: {
|
|
2203
|
+
position: 'fixed',
|
|
2204
|
+
top: 0,
|
|
2205
|
+
left: 0,
|
|
2206
|
+
right: 0,
|
|
2207
|
+
bottom: 0,
|
|
2208
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
2209
|
+
display: 'flex',
|
|
2210
|
+
alignItems: 'center',
|
|
2211
|
+
justifyContent: 'center',
|
|
2212
|
+
},
|
|
2213
|
+
content: {
|
|
2214
|
+
backgroundColor: '#ffffff',
|
|
2215
|
+
borderRadius: '8px',
|
|
2216
|
+
padding: '20px',
|
|
2217
|
+
maxWidth: '600px',
|
|
2218
|
+
width: '100%',
|
|
2219
|
+
maxHeight: '80vh',
|
|
2220
|
+
overflowY: 'auto',
|
|
2221
|
+
},
|
|
2222
|
+
title: {
|
|
2223
|
+
fontSize: '24px',
|
|
2224
|
+
fontWeight: 'bold',
|
|
2225
|
+
marginBottom: '20px',
|
|
2226
|
+
},
|
|
2227
|
+
badgeContainer: {
|
|
2228
|
+
display: 'flex',
|
|
2229
|
+
flexWrap: 'wrap',
|
|
2230
|
+
justifyContent: 'center',
|
|
2231
|
+
},
|
|
2232
|
+
badge: {
|
|
2233
|
+
display: 'flex',
|
|
2234
|
+
flexDirection: 'column',
|
|
2235
|
+
alignItems: 'center',
|
|
2236
|
+
margin: '10px',
|
|
2237
|
+
},
|
|
2238
|
+
badgeIcon: {
|
|
2239
|
+
width: '50px',
|
|
2240
|
+
height: '50px',
|
|
2241
|
+
marginBottom: '5px',
|
|
2242
|
+
},
|
|
2243
|
+
badgeTitle: {
|
|
2244
|
+
fontSize: '14px',
|
|
2245
|
+
textAlign: 'center',
|
|
2246
|
+
},
|
|
2247
|
+
button: {
|
|
2248
|
+
backgroundColor: '#007bff',
|
|
2249
|
+
color: '#ffffff',
|
|
2250
|
+
padding: '10px 20px',
|
|
2251
|
+
borderRadius: '4px',
|
|
2252
|
+
border: 'none',
|
|
2253
|
+
cursor: 'pointer',
|
|
2254
|
+
marginTop: '20px',
|
|
2255
|
+
},
|
|
2256
|
+
},
|
|
2257
|
+
badgesButton: {
|
|
2258
|
+
position: 'fixed',
|
|
2259
|
+
padding: '10px 20px',
|
|
2260
|
+
backgroundColor: '#007bff',
|
|
2261
|
+
color: '#ffffff',
|
|
2262
|
+
border: 'none',
|
|
2263
|
+
borderRadius: '4px',
|
|
2264
|
+
cursor: 'pointer',
|
|
2265
|
+
zIndex: 1000,
|
|
2266
|
+
},
|
|
2267
|
+
};
|
|
2268
|
+
|
|
2253
2269
|
const AchievementContext = React.createContext(undefined);
|
|
2254
2270
|
const useAchievementContext = () => {
|
|
2255
2271
|
const context = React.useContext(AchievementContext);
|
|
@@ -2262,36 +2278,78 @@ const AchievementProvider = ({ children, config, initialState = {}, storageKey =
|
|
|
2262
2278
|
const dispatch = useDispatch();
|
|
2263
2279
|
const metrics = useSelector((state) => state.achievements.metrics);
|
|
2264
2280
|
const unlockedAchievementIds = useSelector((state) => state.achievements.unlockedAchievements);
|
|
2281
|
+
const previouslyAwardedAchievements = useSelector((state) => state.achievements.previouslyAwardedAchievements);
|
|
2265
2282
|
const notifications = useSelector((state) => state.notifications.notifications);
|
|
2266
|
-
const mergedStyles = React.useMemo(() => mergeDeep(defaultStyles, styles), [styles]);
|
|
2267
2283
|
const [currentAchievement, setCurrentAchievement] = React.useState(null);
|
|
2268
2284
|
const [showBadges, setShowBadges] = React.useState(false);
|
|
2269
2285
|
const [showConfetti, setShowConfetti] = React.useState(false);
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2286
|
+
const serializeConfig = (config) => {
|
|
2287
|
+
const serializedConfig = {};
|
|
2288
|
+
Object.entries(config).forEach(([metricName, conditions]) => {
|
|
2289
|
+
serializedConfig[metricName] = conditions.map((condition) => {
|
|
2290
|
+
// Analyze the isConditionMet function to determine type and value
|
|
2291
|
+
const funcString = condition.isConditionMet.toString();
|
|
2292
|
+
let conditionType;
|
|
2293
|
+
let conditionValue;
|
|
2294
|
+
if (funcString.includes('typeof value === "number"') || funcString.includes('typeof value === \'number\'')) {
|
|
2295
|
+
conditionType = 'number';
|
|
2296
|
+
const matches = funcString.match(/value\s*>=?\s*(\d+)/);
|
|
2297
|
+
conditionValue = matches ? parseInt(matches[1]) : 0;
|
|
2298
|
+
}
|
|
2299
|
+
else if (funcString.includes('typeof value === "string"') || funcString.includes('typeof value === \'string\'')) {
|
|
2300
|
+
conditionType = 'string';
|
|
2301
|
+
const matches = funcString.match(/value\s*===?\s*['"](.+)['"]/);
|
|
2302
|
+
conditionValue = matches ? matches[1] : '';
|
|
2303
|
+
}
|
|
2304
|
+
else if (funcString.includes('typeof value === "boolean"') || funcString.includes('typeof value === \'boolean\'')) {
|
|
2305
|
+
conditionType = 'boolean';
|
|
2306
|
+
conditionValue = funcString.includes('=== true');
|
|
2307
|
+
}
|
|
2308
|
+
else if (funcString.includes('instanceof Date')) {
|
|
2309
|
+
conditionType = 'date';
|
|
2310
|
+
const matches = funcString.match(/new Date\(['"](.+)['"]\)/);
|
|
2311
|
+
conditionValue = matches ? matches[1] : new Date().toISOString();
|
|
2312
|
+
}
|
|
2313
|
+
else {
|
|
2314
|
+
// Default to number type if we can't determine the type
|
|
2315
|
+
conditionType = 'number';
|
|
2316
|
+
conditionValue = 1;
|
|
2317
|
+
}
|
|
2318
|
+
return {
|
|
2319
|
+
achievementDetails: condition.achievementDetails,
|
|
2320
|
+
conditionType,
|
|
2321
|
+
conditionValue,
|
|
2322
|
+
};
|
|
2323
|
+
});
|
|
2324
|
+
});
|
|
2325
|
+
return serializedConfig;
|
|
2326
|
+
};
|
|
2327
|
+
const serializedConfig = React.useMemo(() => serializeConfig(config), [config]);
|
|
2281
2328
|
const checkAchievements = React.useCallback(() => {
|
|
2282
2329
|
const newAchievements = [];
|
|
2283
|
-
|
|
2284
|
-
console.error('unlockedAchievements is undefined!');
|
|
2285
|
-
return;
|
|
2286
|
-
}
|
|
2287
|
-
Object.entries(config).forEach(([metricName, conditions]) => {
|
|
2330
|
+
Object.entries(serializedConfig).forEach(([metricName, conditions]) => {
|
|
2288
2331
|
const metricValues = metrics[metricName];
|
|
2289
|
-
if (!metricValues)
|
|
2332
|
+
if (!metricValues)
|
|
2290
2333
|
return;
|
|
2291
|
-
}
|
|
2292
2334
|
conditions.forEach((condition) => {
|
|
2293
|
-
|
|
2294
|
-
|
|
2335
|
+
const isConditionMet = (value) => {
|
|
2336
|
+
switch (condition.conditionType) {
|
|
2337
|
+
case 'number':
|
|
2338
|
+
return typeof value === 'number' && value >= condition.conditionValue;
|
|
2339
|
+
case 'string':
|
|
2340
|
+
return typeof value === 'string' && value === condition.conditionValue;
|
|
2341
|
+
case 'boolean':
|
|
2342
|
+
return typeof value === 'boolean' && value === condition.conditionValue;
|
|
2343
|
+
case 'date':
|
|
2344
|
+
return value instanceof Date &&
|
|
2345
|
+
value.getTime() >= new Date(condition.conditionValue).getTime();
|
|
2346
|
+
default:
|
|
2347
|
+
return false;
|
|
2348
|
+
}
|
|
2349
|
+
};
|
|
2350
|
+
if (metricValues.some((value) => isConditionMet(value)) &&
|
|
2351
|
+
!unlockedAchievementIds.includes(condition.achievementDetails.achievementId) &&
|
|
2352
|
+
!previouslyAwardedAchievements.includes(condition.achievementDetails.achievementId)) {
|
|
2295
2353
|
newAchievements.push(condition.achievementDetails);
|
|
2296
2354
|
}
|
|
2297
2355
|
});
|
|
@@ -2299,11 +2357,12 @@ const AchievementProvider = ({ children, config, initialState = {}, storageKey =
|
|
|
2299
2357
|
if (newAchievements.length > 0) {
|
|
2300
2358
|
newAchievements.forEach((achievement) => {
|
|
2301
2359
|
dispatch(unlockAchievement(achievement.achievementId));
|
|
2360
|
+
dispatch(markAchievementAsAwarded(achievement.achievementId));
|
|
2302
2361
|
dispatch(addNotification(achievement));
|
|
2303
2362
|
});
|
|
2304
2363
|
setShowConfetti(true);
|
|
2305
2364
|
}
|
|
2306
|
-
}, [
|
|
2365
|
+
}, [serializedConfig, metrics, unlockedAchievementIds, previouslyAwardedAchievements, dispatch]);
|
|
2307
2366
|
React.useEffect(() => {
|
|
2308
2367
|
checkAchievements();
|
|
2309
2368
|
}, [metrics, checkAchievements]);
|
|
@@ -2313,49 +2372,67 @@ const AchievementProvider = ({ children, config, initialState = {}, storageKey =
|
|
|
2313
2372
|
}
|
|
2314
2373
|
}, [notifications, currentAchievement]);
|
|
2315
2374
|
const showBadgesModal = () => setShowBadges(true);
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2375
|
+
React.useEffect(() => {
|
|
2376
|
+
dispatch(initialize({
|
|
2377
|
+
config: serializedConfig,
|
|
2378
|
+
initialState,
|
|
2379
|
+
storageKey,
|
|
2380
|
+
}));
|
|
2381
|
+
}, [dispatch, serializedConfig, initialState, storageKey]);
|
|
2382
|
+
return (React.createElement(AchievementContext.Provider, { value: {
|
|
2383
|
+
updateMetrics: (newMetrics) => {
|
|
2384
|
+
if (typeof newMetrics === 'function') {
|
|
2385
|
+
const currentMetrics = metrics;
|
|
2386
|
+
const updatedMetrics = newMetrics(currentMetrics);
|
|
2387
|
+
dispatch(setMetrics(updatedMetrics));
|
|
2388
|
+
}
|
|
2389
|
+
else {
|
|
2390
|
+
dispatch(setMetrics(newMetrics));
|
|
2391
|
+
}
|
|
2392
|
+
},
|
|
2393
|
+
unlockedAchievements: unlockedAchievementIds,
|
|
2394
|
+
resetStorage: () => {
|
|
2395
|
+
localStorage.removeItem(storageKey);
|
|
2396
|
+
dispatch(resetAchievements());
|
|
2397
|
+
},
|
|
2398
|
+
} },
|
|
2323
2399
|
children,
|
|
2400
|
+
React.createElement(ConfettiWrapper, { show: showConfetti }),
|
|
2324
2401
|
React.createElement(AchievementModal$1, { isOpen: !!currentAchievement, achievement: currentAchievement, onClose: () => {
|
|
2325
2402
|
setCurrentAchievement(null);
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2403
|
+
dispatch(clearNotifications());
|
|
2404
|
+
setShowConfetti(false);
|
|
2405
|
+
}, styles: styles.achievementModal || defaultStyles.achievementModal, icons: icons }),
|
|
2406
|
+
React.createElement(BadgesButton$1, { onClick: showBadgesModal, position: badgesButtonPosition, styles: styles.badgesButton || defaultStyles.badgesButton, unlockedAchievements: [...unlockedAchievementIds, ...previouslyAwardedAchievements]
|
|
2407
|
+
.filter((id, index, self) => self.indexOf(id) === index) // Remove duplicates
|
|
2408
|
+
.map(id => {
|
|
2409
|
+
const achievement = Object.values(serializedConfig)
|
|
2410
|
+
.flat()
|
|
2411
|
+
.find(condition => condition.achievementDetails.achievementId === id);
|
|
2412
|
+
return achievement === null || achievement === void 0 ? void 0 : achievement.achievementDetails;
|
|
2413
|
+
}).filter((a) => !!a) }),
|
|
2414
|
+
React.createElement(BadgesModal$1, { isOpen: showBadges, achievements: [...unlockedAchievementIds, ...previouslyAwardedAchievements]
|
|
2415
|
+
.filter((id, index, self) => self.indexOf(id) === index) // Remove duplicates
|
|
2416
|
+
.map(id => {
|
|
2417
|
+
const achievement = Object.values(serializedConfig)
|
|
2418
|
+
.flat()
|
|
2419
|
+
.find(condition => condition.achievementDetails.achievementId === id);
|
|
2420
|
+
return achievement === null || achievement === void 0 ? void 0 : achievement.achievementDetails;
|
|
2421
|
+
}).filter((a) => !!a), onClose: () => setShowBadges(false), styles: styles.badgesModal || defaultStyles.badgesModal, icons: icons })));
|
|
2422
|
+
};
|
|
2423
|
+
|
|
2424
|
+
const useAchievementState = () => {
|
|
2425
|
+
const metrics = useSelector((state) => state.achievements.metrics);
|
|
2426
|
+
const previouslyAwardedAchievements = useSelector((state) => state.achievements.previouslyAwardedAchievements);
|
|
2427
|
+
return {
|
|
2428
|
+
metrics,
|
|
2429
|
+
previouslyAwardedAchievements,
|
|
2430
|
+
};
|
|
2333
2431
|
};
|
|
2334
|
-
function isObject(item) {
|
|
2335
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
2336
|
-
}
|
|
2337
|
-
function mergeDeep(target, source) {
|
|
2338
|
-
const output = Object.assign({}, target);
|
|
2339
|
-
if (isObject(target) && isObject(source)) {
|
|
2340
|
-
Object.keys(source).forEach((key) => {
|
|
2341
|
-
if (isObject(source[key])) {
|
|
2342
|
-
if (!(key in target)) {
|
|
2343
|
-
output[key] = source[key];
|
|
2344
|
-
}
|
|
2345
|
-
else {
|
|
2346
|
-
output[key] = mergeDeep(target[key], source[key]);
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
else {
|
|
2350
|
-
output[key] = source[key];
|
|
2351
|
-
}
|
|
2352
|
-
});
|
|
2353
|
-
}
|
|
2354
|
-
return output;
|
|
2355
|
-
}
|
|
2356
2432
|
|
|
2357
2433
|
exports.AchievementProvider = AchievementProvider;
|
|
2358
2434
|
exports.ConfettiWrapper = ConfettiWrapper;
|
|
2359
2435
|
exports.achievementReducer = achievementSlice$1;
|
|
2360
2436
|
exports.notificationReducer = notificationSlice$1;
|
|
2361
2437
|
exports.useAchievement = useAchievementContext;
|
|
2438
|
+
exports.useAchievementState = useAchievementState;
|