import { createStore } from "./chunk-2TJP56W3.js"; import "./chunk-PLDDJCW6.js"; // node_modules/.pnpm/@dhmk+utils@4.4.1/node_modules/@dhmk/utils/esm/error.js var __extends = /* @__PURE__ */ function() { var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); var CustomError = ( /** @class */ function(_super) { __extends(CustomError2, _super); function CustomError2() { var _newTarget = this.constructor; var _a; var _this = _super.call(this) || this; Object.setPrototypeOf(_this, _newTarget.prototype); (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call( // a key to successful extending Error, _this, _newTarget ); return _this; } return CustomError2; }(Error) ); var DomainError = ( /** @class */ function(_super) { __extends(DomainError2, _super); function DomainError2(a1, a2, a3, a4) { var _this = _super.call(this) || this; _this.context = a1; _this.error = a2 instanceof Error ? a2 : void 0; _this.code = (_this.error ? a3 : a2) || 0; _this.meta = _this.error ? a4 : a3; if (_this.error) { _this.message = _this.error.message; _this.toString = _this.error.toString.bind(_this.error); } return _this; } return DomainError2; }(CustomError) ); // node_modules/.pnpm/@dhmk+utils@4.4.1/node_modules/@dhmk/utils/esm/types.js var CancelledResult = ( /** @class */ /* @__PURE__ */ function() { function CancelledResult2() { } return CancelledResult2; }() ); var Cancelled = new CancelledResult(); // node_modules/.pnpm/@dhmk+utils@4.4.1/node_modules/@dhmk/utils/esm/std.js var __assign = function() { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var id = function(x) { return x; }; var shallowEqual = function(a, b) { var ka = Object.keys(a); var kb = Object.keys(b); return ka.length === kb.length && ka.every(function(k) { return a[k] === b[k]; }); }; function objectFrom(entries) { return Array.from(entries).reduce(function(res, _a) { var k = _a[0], v = _a[1]; res[k] = v; return res; }, {}); } function objectMap(src, mapValue, mapKey, mapSymbol) { if (mapKey === void 0) { mapKey = id; } if (mapSymbol === void 0) { mapSymbol = id; } return objectFrom(Object.keys(src).map(function(k) { return [mapKey(k, src[k], src), mapValue(src[k], k, src)]; }).concat(Object.getOwnPropertySymbols(src).map(function(k) { return [ k, mapSymbol(src[k], k, src) ]; }))); } var mergeDeepRec = function(a, b) { if (!isPlainObject(a) || !isPlainObject(b)) return b; var res = __assign(__assign({}, a), b); for (var k in b) { res[k] = mergeDeepRec(a[k], b[k]); } return res; }; var mergeDeep2 = function(a, b) { return mergeDeepRec(a, typeof b === "function" ? b(a) : b); }; var mergeDeep = function(a, b) { return b ? mergeDeep2(a, b) : function(b2) { return mergeDeep2(b2, a); }; }; var isPlainObject = function(x) { return !!x && typeof x === "object" && Object.getPrototypeOf(x) === Object.prototype; }; // node_modules/.pnpm/@dhmk+utils@4.4.1/node_modules/@dhmk/utils/esm/misc.js function createCaseConverter(mapKey) { return function convertCase(obj) { if (isPlainObject(obj)) { return objectMap(obj, convertCase, mapKey); } else if (Array.isArray(obj)) return obj.map(convertCase); else return obj; }; } var snakeToCamelCase = createCaseConverter(function(k) { return k.replace(/_(\w)/g, function(_, x) { return x.toUpperCase(); }); }); var camelToSnakeCase = createCaseConverter(function(k) { return k.replace(/([A-Z])([a-z0-9])/g, function(_, x1, x2) { return "_" + x1.toLowerCase() + x2; }).replace(/([A-Z]+)/g, function(_, x) { return "_" + x.toLowerCase(); }); }); // node_modules/.pnpm/@dhmk+utils@4.4.1/node_modules/@dhmk/utils/esm/lens.js var __assign2 = function() { __assign2 = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign2.apply(this, arguments); }; var getIn = function(x, path) { return path.reduce(function(src, k) { return src[k]; }, x); }; var updateIn = function(x, path, updater) { if (path.length === 0) { return updater(x); } var k = path[0], rest = path.slice(1); var value = updateIn(x[k], rest, updater); return Array.isArray(x) ? arraySet(x, Number(k), value) : objectSet(x, k, value); }; var setIn = function(x, path, v) { return updateIn(x, path, function() { return v; }); }; var arraySet = function(x, k, v) { return x.map(function(_v, i) { return i === k ? v : _v; }); }; var objectSet = function(x, k, v) { var _a; return __assign2(__assign2({}, x), (_a = {}, _a[k] = v, _a)); }; // node_modules/.pnpm/@dhmk+zustand-lens@5.0.0_zu_f4d5fd4b94829d1baae72c44d4297fa8/node_modules/@dhmk/zustand-lens/esm/core.js var __assign3 = function() { __assign3 = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign3.apply(this, arguments); }; var __spreadArray = function(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; var meta = Symbol("lens meta"); var storeContext = Symbol("store context"); function createLens(set, get, path) { var normPath = path === void 0 ? void 0 : typeof path === "string" ? [path] : path; var _set = function(partial, replace) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } return set.apply(void 0, __spreadArray([ function(parentValue) { var _a, _b, _c, _d; var ourOldValue = normPath ? getIn(parentValue, normPath) : parentValue; var ourTmpValue = typeof partial === "function" ? partial(ourOldValue) : partial; var isPlain = isPlainObject(ourOldValue); var ourOldValue2 = normPath ? getIn(get(), normPath) : get(); var isDraft = isPlain && ourOldValue !== ourOldValue2; if (isDraft) { var draft = ourOldValue; if (ourTmpValue) Object.assign(draft, ourTmpValue); var pp = ( /*draft*/ (_b = (_a = ourOldValue2[meta]) === null || _a === void 0 ? void 0 : _a.postprocess) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([ _a, draft, ourOldValue2 ], args, false)) ); if (pp) Object.assign(draft, pp); return; } var ourTmpValue2 = replace || !isPlain ? ourTmpValue : __assign3(__assign3({}, ourOldValue), ourTmpValue); var ourNextValue = isPlain ? __assign3(__assign3({}, ourTmpValue2), (_d = (_c = ourTmpValue2[meta]) === null || _c === void 0 ? void 0 : _c.postprocess) === null || _d === void 0 ? void 0 : _d.call.apply(_d, __spreadArray([ _c, ourTmpValue2, ourOldValue ], args, false))) : ourTmpValue2; var isSame = isPlain ? shallowEqual(ourOldValue, ourNextValue) : Object.is(ourOldValue, ourNextValue); return isSame ? parentValue : normPath ? setIn(parentValue, normPath, ourNextValue) : ourNextValue; }, normPath ? false : replace ], args, false)); }; var _get = function() { return normPath ? getIn(get(), normPath) : get(); }; return [_set, _get]; } var LENS_TAG = "@dhmk/LENS_TAG"; var isLens = function(x) { return !!x && x[LENS_TAG]; }; function lens(fn) { var self = function(set, get, api, ctx) { var _a = createLens(set, get, ctx.relativePath), _set = _a[0], _get = _a[1]; ctx.set = _set; ctx.get = _get; return fn(_set, _get, api, ctx); }; self[LENS_TAG] = true; return self; } var findLensAndCreate = function(x, parentCtx) { var _a, _b; var res = x; if (isPlainObject(x)) { res = {}; var keys = Array().concat( Object.getOwnPropertyNames(x), (_b = (_a = Object.getOwnPropertySymbols) === null || _a === void 0 ? void 0 : _a.call(Object, x)) !== null && _b !== void 0 ? _b : [] // ie 11 ); keys.forEach(function(k) { var _a2; var v = x[k]; if (typeof k === "symbol") { res[k] = v; return; } var nextSet = parentCtx.set; var nextGet = parentCtx.get; var nextRelativePath = parentCtx.relativePath.concat(k); if (isLens(v)) { var lensCtx_1 = { set: void 0, // will be set by `lens` function get: void 0, // see `set` api: parentCtx.api, rootPath: parentCtx.rootPath.concat(k), relativePath: parentCtx.relativePath.concat(k), atomic: parentCtx.atomic === atomicStub ? atomicStubWithWarning : parentCtx.atomic }; var setterFn_1 = function(x2) { return x2(); }; var set = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return parentCtx.atomic(function() { return setterFn_1(function() { return parentCtx.set.apply(parentCtx, args); }, lensCtx_1); }); }; v = v(set, parentCtx.get, parentCtx.api, lensCtx_1); if ((_a2 = v[meta]) === null || _a2 === void 0 ? void 0 : _a2.setter) setterFn_1 = v[meta].setter; nextSet = lensCtx_1.set; nextGet = lensCtx_1.get; nextRelativePath = []; } res[k] = findLensAndCreate(v, { set: nextSet, get: nextGet, api: parentCtx.api, rootPath: parentCtx.rootPath.concat(k), relativePath: nextRelativePath, atomic: parentCtx.atomic }); }); } return res; }; var withLensesImpl = function(config) { return function(set, get, api) { var _a, _b, _c; var atomic2 = (_b = (_a = api[storeContext]) === null || _a === void 0 ? void 0 : _a.atomic) !== null && _b !== void 0 ? _b : atomicStub; var setterFn = function(x) { return x(); }; var setFn = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return atomic2(function() { return setterFn(function() { return set.apply(void 0, args); }, ctx); }); }; var _set = createLens(setFn, get, void 0)[0]; var ctx = { set: _set, get, api, rootPath: [], relativePath: [], atomic: atomic2 }; var obj = typeof config === "function" ? config(_set, get, api) : config; var res = findLensAndCreate(obj, ctx); if ((_c = res[meta]) === null || _c === void 0 ? void 0 : _c.setter) setterFn = res[meta].setter; return res; }; }; var withLenses = withLensesImpl; var atomicStub = function(fn) { return fn(); }; var atomicStubWithWarning = function(fn) { console.warn("You must include `atomic` middleware."); return atomicStub(fn); }; var atomicImpl = function(config) { return function(set, get, api) { var _a; var tempStore = createStore(get); var counter = 0; var atomic2 = function(fn) { if (++counter === 1) { tempStore.setState(get()); } try { fn(); } finally { if (--counter === 0) { set(tempStore.getState()); } } }; var _set = function() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } atomic2(function() { return tempStore.setState.apply(tempStore, args); }); }; var _get = function() { return counter ? tempStore.getState() : get(); }; return config(_set, _get, __assign3(__assign3({}, api), (_a = { setState: _set, getState: _get }, _a[storeContext] = { atomic: atomic2 }, _a))); }; }; var atomic = atomicImpl; // node_modules/.pnpm/@dhmk+zustand-lens@5.0.0_zu_f4d5fd4b94829d1baae72c44d4297fa8/node_modules/@dhmk/zustand-lens/esm/helpers.js var mergeDeepLeft = function(a, b) { return mergeDeep(b, a); }; var customSetter = function(setter) { return function(fn) { return function(set, get, api, ctx) { return fn(setter(set), get, api, ctx); }; }; }; var namedSetter = customSetter(function(set) { return function(partial, name, replace) { return set(partial, replace, name); }; }); function subscribe(store, selector, effect, options) { if (options === void 0) { options = {}; } var _a = options.equalityFn, equalityFn = _a === void 0 ? Object.is : _a, _b = options.fireImmediately, fireImmediately = _b === void 0 ? false : _b; var curr = selector(store.getState()); if (fireImmediately) effect(curr, curr); return store.subscribe(function(state) { var next = selector(state); if (!equalityFn(next, curr)) { var prev = curr; effect(curr = next, prev); } }); } function watch(selector, effect, options) { if (options === void 0) { options = {}; } var _a = options.equalityFn, equalityFn = _a === void 0 ? Object.is : _a, _b = options.fireImmediately, fireImmediately = _b === void 0 ? false : _b; var curr; if (fireImmediately) effect(void 0, void 0); return function(set, ctx) { if (!curr) curr = selector(ctx.get()); set(); var next = selector(ctx.get()); if (!equalityFn(next, curr)) { var prev = curr; effect(curr = next, prev); } }; } function combineWatchers() { var fns = []; for (var _i = 0; _i < arguments.length; _i++) { fns[_i] = arguments[_i]; } var initialized; var runWatchers = function(ctx) { return fns.forEach(function(fn) { return fn(function() { }, ctx); }); }; return function(set, ctx) { if (!initialized) { initialized = true; runWatchers(ctx); } set(); runWatchers(ctx); }; } var persist = Symbol("persist"); function persistOptions(conf) { var _a; return _a = {}, _a[persist] = conf, _a; } function walk(x, fn) { return isPlainObject(x) ? objectMap(fn(x), function(v) { return walk(v, fn); }) : x; } var zustandPersistOptions = { merge: function(persistedState, currentState) { if (persistedState === void 0) { persistedState = {}; } return walk(mergeDeep(currentState, persistedState), function(x) { var _a, _b, _c; return (_c = (_b = (_a = x[persist]) === null || _a === void 0 ? void 0 : _a.load) === null || _b === void 0 ? void 0 : _b.call(_a, x)) !== null && _c !== void 0 ? _c : x; }); }, partialize: function(state) { return walk(state, function(x) { var _a, _b, _c; return (_c = (_b = (_a = x[persist]) === null || _a === void 0 ? void 0 : _a.save) === null || _b === void 0 ? void 0 : _b.call(_a, x)) !== null && _c !== void 0 ? _c : x; }); } }; persistOptions.merge = zustandPersistOptions.merge; persistOptions.partialize = zustandPersistOptions.partialize; export { atomic, combineWatchers, createLens, customSetter, lens, mergeDeep, mergeDeepLeft, meta, namedSetter, persistOptions, subscribe, watch, withLenses }; //# sourceMappingURL=@dhmk_zustand-lens.js.map