"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("zustand"),r=require("lodash"),n=require("./utils/loadUserSettings.js"),a=require("./utils/subscribeToSettingsSave.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}exports.createUserSettingsStore=function(e){var i=e.userId,u=t.createStore()((function(e,t){return{settings:{},manuallyChanged:{},loadState:"idle",error:null,setSetting:function(n,a){var i=t().settings;if(!r.isEqual(i[n],a)){var u=t().manuallyChanged;e({settings:s(s({},i),{},o.default({},n,a)),manuallyChanged:u[n]?u:s(s({},u),{},o.default({},n,!0))})}},loadSettings:function(){return n.loadUserSettings(u,i)},isLoading:function(){return"loading"===t().loadState},isLoaded:function(){return"loaded"===t().loadState},hasManuallyChanged:function(e){return!0===t().manuallyChanged[e]}}}));return i&&a.subscribeToSettingsSave(u,i),u};
//# sourceMappingURL=createUserSettingsStore.js.map
