@superbright/indexeddb-orm 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +5 -5
  2. package/dist/adapters/structured-store.cjs +1 -1
  3. package/dist/adapters/structured-store.cjs.map +1 -1
  4. package/dist/adapters/structured-store.d.ts +1 -1
  5. package/dist/adapters/structured-store.mjs +1 -1
  6. package/dist/adapters/structured-store.mjs.map +1 -1
  7. package/dist/adapters/zustand-store.cjs +1 -1
  8. package/dist/adapters/zustand-store.cjs.map +1 -1
  9. package/dist/adapters/zustand-store.mjs +12 -11
  10. package/dist/adapters/zustand-store.mjs.map +1 -1
  11. package/dist/base/property.d.ts +2 -2
  12. package/dist/base/unit.d.ts +12 -12
  13. package/dist/base/user.d.ts +4 -4
  14. package/dist/features/analytics/MixpanelProvider.cjs +1 -1
  15. package/dist/features/analytics/MixpanelProvider.cjs.map +1 -1
  16. package/dist/features/analytics/MixpanelProvider.mjs +22 -20
  17. package/dist/features/analytics/MixpanelProvider.mjs.map +1 -1
  18. package/dist/features/filters/transformers.cjs +2 -0
  19. package/dist/features/filters/transformers.cjs.map +1 -0
  20. package/dist/features/filters/transformers.d.ts +31 -0
  21. package/dist/features/filters/transformers.mjs +110 -0
  22. package/dist/features/filters/transformers.mjs.map +1 -0
  23. package/dist/features/units/transformers.cjs +1 -1
  24. package/dist/features/units/transformers.cjs.map +1 -1
  25. package/dist/features/units/transformers.d.ts +12 -10
  26. package/dist/features/units/transformers.mjs +42 -38
  27. package/dist/features/units/transformers.mjs.map +1 -1
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.mjs +80 -76
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/schema.cjs +1 -1
  33. package/dist/schema.cjs.map +1 -1
  34. package/dist/schema.d.ts +754 -715
  35. package/dist/schema.mjs +104 -101
  36. package/dist/schema.mjs.map +1 -1
  37. package/dist/stores/store.cjs +1 -1
  38. package/dist/stores/store.cjs.map +1 -1
  39. package/dist/stores/store.mjs +229 -240
  40. package/dist/stores/store.mjs.map +1 -1
  41. package/package.json +1 -1
@@ -1,12 +1,13 @@
1
- import { kvGet as F, kvSet as b } from "../storage.mjs";
2
- import { UnifiedStoreDataSchema as f, UserPropertyStateSchema as U, UnitSchema as g, PropertySchema as h } from "../schema.mjs";
3
- import { validate as y } from "../validation.mjs";
4
- const w = {
5
- availability: void 0,
6
- bedrooms: void 0,
7
- cost: void 0,
1
+ import { kvGet as P, kvSet as g } from "../storage.mjs";
2
+ import { UnifiedStoreDataSchema as S, UserPropertyStateSchema as v, UnitSchema as w, PropertySchema as f } from "../schema.mjs";
3
+ import { validate as d } from "../validation.mjs";
4
+ import { transformFiltersToUnitsSearchParams as m } from "../features/filters/transformers.mjs";
5
+ const h = {
6
+ date_availability: void 0,
7
+ qty_bedrooms: void 0,
8
+ base_price: void 0,
8
9
  highlights: void 0
9
- }, S = {
10
+ }, y = {
10
11
  // Property data
11
12
  properties: {},
12
13
  currentPropertyId: null,
@@ -14,66 +15,48 @@ const w = {
14
15
  hasPreviouslySearched: [],
15
16
  // App data
16
17
  unitResults: [],
17
- filters: w,
18
- tempFilters: w,
18
+ filters: h,
19
+ tempFilters: h,
19
20
  apiFilters: {
20
21
  limit: 10,
21
- page: 1
22
+ page: 1,
23
+ sortBy: "relevance"
22
24
  },
23
25
  resultsMode: "all",
24
26
  resolvedQuestionnaireValues: {},
25
27
  sortBy: "relevance"
26
- }, I = (o) => o == null ? [] : Array.isArray(o) ? o : [o], m = (o) => I(o).flatMap((t) => {
27
- if (t == null) return [];
28
- if (Array.isArray(t)) return t;
29
- if (typeof t == "object" && "value" in t) {
30
- const r = t.value;
31
- return Array.isArray(r) ? r : r != null ? [r] : [];
32
- }
33
- return [t];
34
- }), P = (o) => m(o).flatMap((t) => Array.isArray(t) ? t : [t]).map((t) => String(t)).map((t) => t.trim()).filter((t) => t.length > 0), R = (o) => m(o).map((t) => {
35
- if (typeof t == "number" && Number.isFinite(t)) return t;
36
- const r = Number(t);
37
- return Number.isFinite(r) ? r : null;
38
- }).filter((t) => t !== null), v = (o) => {
39
- if (o == null) return null;
40
- if (typeof o == "number") return Number.isFinite(o) ? o : null;
41
- if (typeof o == "object" && "value" in o)
42
- return v(o.value);
43
- const t = Number(o);
44
- return Number.isFinite(t) ? t : null;
45
28
  };
46
- class A {
29
+ class F {
47
30
  /**
48
31
  * Resolves the persisted unified store snapshot, coercing legacy shapes into the latest schema
49
32
  * and sanitizing invalid entries where possible.
50
33
  */
51
34
  async getState() {
52
- const t = await F("app");
35
+ const t = await P("app");
53
36
  if (!t)
54
- return S;
55
- const r = {
56
- ...S,
37
+ return y;
38
+ const e = {
39
+ ...y,
57
40
  ...t,
58
41
  properties: t.properties ?? {},
59
42
  unitResults: t.unitResults ?? [],
60
43
  currentPropertyId: t.currentPropertyId == null ? null : String(t.currentPropertyId),
61
44
  currentPropertySlug: t.currentPropertySlug ?? null,
62
45
  hasPreviouslySearched: Array.isArray(t.hasPreviouslySearched) ? t.hasPreviouslySearched.map(String) : []
63
- }, e = f.safeParse(r);
64
- if (e.success) return e.data;
65
- const i = Object.entries(r.properties ?? {}).reduce((p, [l, c]) => {
66
- const d = U.safeParse(c);
67
- return d.success && (p[l] = d.data), p;
68
- }, {}), s = (Array.isArray(r.unitResults) ? r.unitResults : r.unitResults && typeof r.unitResults == "object" ? Object.values(r.unitResults) : []).reduce((p, l) => {
69
- const c = g.safeParse(l);
46
+ }, r = S.safeParse(e);
47
+ if (r.success) return r.data;
48
+ const s = Object.entries(e.properties ?? {}).reduce((p, [u, c]) => {
49
+ const l = v.safeParse(c);
50
+ return l.success && (p[u] = l.data), p;
51
+ }, {}), i = (Array.isArray(e.unitResults) ? e.unitResults : e.unitResults && typeof e.unitResults == "object" ? Object.values(e.unitResults) : []).reduce((p, u) => {
52
+ const c = w.safeParse(u);
70
53
  return c.success && p.push(c.data), p;
71
- }, []), a = {
72
- ...r,
73
- properties: i,
74
- unitResults: s
75
- }, u = f.safeParse(a);
76
- return u.success ? u.data : S;
54
+ }, []), n = {
55
+ ...e,
56
+ properties: s,
57
+ unitResults: i
58
+ }, o = S.safeParse(n);
59
+ return o.success ? o.data : y;
77
60
  }
78
61
  /**
79
62
  * Applies an updater function to the current store state, validates the result, and persists it.
@@ -81,8 +64,8 @@ class A {
81
64
  * @param updater - Pure function that maps the current state to the next state.
82
65
  */
83
66
  async setState(t) {
84
- const r = await this.getState(), e = t(r), i = f.parse(e);
85
- await b("app", i);
67
+ const e = await this.getState(), r = t(e), s = S.parse(r);
68
+ await g("app", s);
86
69
  }
87
70
  /**
88
71
  * Polls the persisted state until a current property pointer is available or the timeout elapses.
@@ -92,14 +75,14 @@ class A {
92
75
  * @throws Error if the property pointer is not set before the timeout expires.
93
76
  */
94
77
  async waitForCurrentProperty(t = 1e3) {
95
- const r = Date.now() + t;
96
- for (; Date.now() < r; ) {
97
- const n = await this.getState(), s = n.currentPropertyId;
98
- if (s && n.properties[s]) return s;
99
- await new Promise((a) => setTimeout(a, 16));
78
+ const e = Date.now() + t;
79
+ for (; Date.now() < e; ) {
80
+ const a = await this.getState(), i = a.currentPropertyId;
81
+ if (i && a.properties[i]) return i;
82
+ await new Promise((n) => setTimeout(n, 16));
100
83
  }
101
- const e = await this.getState(), i = e.currentPropertyId;
102
- if (i && e.properties[i]) return i;
84
+ const r = await this.getState(), s = r.currentPropertyId;
85
+ if (s && r.properties[s]) return s;
103
86
  throw new Error("UnifiedStore: current property was not initialized in time");
104
87
  }
105
88
  // === PROPERTY OPERATIONS ===
@@ -109,21 +92,21 @@ class A {
109
92
  * @param propertyId - Identifier used to track the property.
110
93
  * @param slug - Canonical slug associated with the property.
111
94
  */
112
- async initializeProperty(t, r) {
113
- const e = String(t);
114
- await this.setState((i) => i.properties && i.properties[e] ? {
115
- ...i,
116
- currentPropertyId: e,
117
- currentPropertySlug: r
95
+ async initializeProperty(t, e) {
96
+ const r = String(t);
97
+ await this.setState((s) => s.properties && s.properties[r] ? {
98
+ ...s,
99
+ currentPropertyId: r,
100
+ currentPropertySlug: e
118
101
  } : {
119
- ...i,
120
- currentPropertyId: e,
121
- currentPropertySlug: r,
102
+ ...s,
103
+ currentPropertyId: r,
104
+ currentPropertySlug: e,
122
105
  properties: {
123
- ...i.properties,
124
- [e]: {
125
- id: e,
126
- slug: r,
106
+ ...s.properties,
107
+ [r]: {
108
+ id: r,
109
+ slug: e,
127
110
  favoritedUnits: [],
128
111
  tourContactedOn: null,
129
112
  viewedUnits: [],
@@ -140,14 +123,14 @@ class A {
140
123
  * @param units - Raw units collection returned by an API call.
141
124
  * @param schema - Optional override schema when the default `UnitSchema` is not sufficient.
142
125
  */
143
- async setUnitResults(t, r) {
144
- const e = r ?? g, i = [];
145
- (Array.isArray(t) ? t : t && typeof t == "object" ? Object.values(t) : []).forEach((s, a) => {
146
- const u = y(e, s, `unitResults[${a}]`);
147
- u && i.push(u);
148
- }), await this.setState((s) => ({
149
- ...s,
150
- unitResults: i
126
+ async setUnitResults(t, e) {
127
+ const r = e ?? w, s = [];
128
+ (Array.isArray(t) ? t : t && typeof t == "object" ? Object.values(t) : []).forEach((i, n) => {
129
+ const o = d(r, i, `unitResults[${n}]`);
130
+ o && s.push(o);
131
+ }), await this.setState((i) => ({
132
+ ...i,
133
+ unitResults: s
151
134
  }));
152
135
  }
153
136
  /**
@@ -167,22 +150,22 @@ class A {
167
150
  * @param data - New property payload.
168
151
  * @param schema - Optional schema override used for validation.
169
152
  */
170
- async setPropertyData(t, r, e) {
171
- const i = String(t), n = e ?? h;
172
- await this.setState((s) => {
173
- const a = s.properties[i];
174
- if (!a) return s;
175
- const u = y(n, r, `properties.${i}.data`);
176
- return u ? {
177
- ...s,
153
+ async setPropertyData(t, e, r) {
154
+ const s = String(t), a = r ?? f;
155
+ await this.setState((i) => {
156
+ const n = i.properties[s];
157
+ if (!n) return i;
158
+ const o = d(a, e, `properties.${s}.data`);
159
+ return o ? {
160
+ ...i,
178
161
  properties: {
179
- ...s.properties,
180
- [i]: {
181
- ...a,
182
- data: u
162
+ ...i.properties,
163
+ [s]: {
164
+ ...n,
165
+ data: o
183
166
  }
184
167
  }
185
- } : s;
168
+ } : i;
186
169
  });
187
170
  }
188
171
  /**
@@ -192,46 +175,46 @@ class A {
192
175
  * @param partial - Partial payload to merge.
193
176
  * @param schema - Optional schema override for validation.
194
177
  */
195
- async mergePropertyData(t, r, e) {
196
- const i = String(t), n = e ?? h;
197
- await this.setState((s) => {
198
- const a = s.properties[i];
199
- if (!a) return s;
200
- const u = a.data;
201
- if (!u) {
202
- const d = y(n, r, `properties.${i}.data`);
203
- return d ? {
204
- ...s,
178
+ async mergePropertyData(t, e, r) {
179
+ const s = String(t), a = r ?? f;
180
+ await this.setState((i) => {
181
+ const n = i.properties[s];
182
+ if (!n) return i;
183
+ const o = n.data;
184
+ if (!o) {
185
+ const l = d(a, e, `properties.${s}.data`);
186
+ return l ? {
187
+ ...i,
205
188
  properties: {
206
- ...s.properties,
207
- [i]: {
208
- ...a,
209
- data: d
189
+ ...i.properties,
190
+ [s]: {
191
+ ...n,
192
+ data: l
210
193
  }
211
194
  }
212
- } : s;
195
+ } : i;
213
196
  }
214
- const p = n.partial(), l = y(
197
+ const p = a.partial(), u = d(
215
198
  p,
216
- r,
217
- `properties.${i}.data.partial`
199
+ e,
200
+ `properties.${s}.data.partial`
218
201
  );
219
- if (!l) return s;
220
- const c = y(
221
- n,
222
- { ...u, ...l },
223
- `properties.${i}.data`
202
+ if (!u) return i;
203
+ const c = d(
204
+ a,
205
+ { ...o, ...u },
206
+ `properties.${s}.data`
224
207
  );
225
208
  return c ? {
226
- ...s,
209
+ ...i,
227
210
  properties: {
228
- ...s.properties,
229
- [i]: {
230
- ...a,
211
+ ...i.properties,
212
+ [s]: {
213
+ ...n,
231
214
  data: c
232
215
  }
233
216
  }
234
- } : s;
217
+ } : i;
235
218
  });
236
219
  }
237
220
  // Accepts a full API property object, validates, and stores it into the
@@ -242,31 +225,31 @@ class A {
242
225
  * @param apiProperty - Raw property object returned by an API.
243
226
  * @param schema - Optional schema override.
244
227
  */
245
- async upsertPropertyFromApi(t, r) {
246
- const i = (r ?? h).parse(t), n = i.id ?? i.propertyId;
247
- if (n == null)
228
+ async upsertPropertyFromApi(t, e) {
229
+ const s = (e ?? f).parse(t), a = s.id ?? s.propertyId;
230
+ if (a == null)
248
231
  throw new Error("upsertPropertyFromApi: property id is required");
249
- const s = String(n), a = i.slug ?? void 0;
250
- await this.setState((u) => {
251
- const p = u.properties[s], l = p ? {
232
+ const i = String(a), n = s.slug ?? void 0;
233
+ await this.setState((o) => {
234
+ const p = o.properties[i], u = p ? {
252
235
  ...p,
253
- ...a ? { slug: a } : {},
254
- data: i
236
+ ...n ? { slug: n } : {},
237
+ data: s
255
238
  } : {
256
- id: s,
257
- slug: a ?? "",
239
+ id: i,
240
+ slug: n ?? "",
258
241
  favoritedUnits: [],
259
242
  tourContactedOn: null,
260
243
  viewedUnits: [],
261
244
  questionnaireResults: null,
262
245
  tourContactData: null,
263
- data: i
246
+ data: s
264
247
  };
265
248
  return {
266
- ...u,
249
+ ...o,
267
250
  properties: {
268
- ...u.properties,
269
- [s]: l
251
+ ...o.properties,
252
+ [i]: u
270
253
  }
271
254
  };
272
255
  });
@@ -277,12 +260,12 @@ class A {
277
260
  * @param propertyId - Property identifier to focus.
278
261
  * @param slug - Optional slug override.
279
262
  */
280
- async setCurrentProperty(t, r) {
281
- const e = String(t);
282
- await this.setState((i) => ({
283
- ...i,
284
- currentPropertyId: e,
285
- currentPropertySlug: r || i.currentPropertySlug
263
+ async setCurrentProperty(t, e) {
264
+ const r = String(t);
265
+ await this.setState((s) => ({
266
+ ...s,
267
+ currentPropertyId: r,
268
+ currentPropertySlug: e || s.currentPropertySlug
286
269
  }));
287
270
  }
288
271
  /**
@@ -291,8 +274,8 @@ class A {
291
274
  * @param slug - New slug to persist.
292
275
  */
293
276
  async setCurrentPropertySlug(t) {
294
- await this.setState((r) => ({
295
- ...r,
277
+ await this.setState((e) => ({
278
+ ...e,
296
279
  currentPropertySlug: t
297
280
  }));
298
281
  }
@@ -302,10 +285,10 @@ class A {
302
285
  * @param slug - Slug to record.
303
286
  */
304
287
  async setHasPreviouslySearched(t) {
305
- await this.setState((r) => ({
306
- ...r,
288
+ await this.setState((e) => ({
289
+ ...e,
307
290
  hasPreviouslySearched: Array.from(
308
- /* @__PURE__ */ new Set([...r.hasPreviouslySearched, t])
291
+ /* @__PURE__ */ new Set([...e.hasPreviouslySearched, t])
309
292
  )
310
293
  }));
311
294
  }
@@ -315,19 +298,19 @@ class A {
315
298
  * @param unitId - Unit identifier to toggle.
316
299
  */
317
300
  async toggleFavorite(t) {
318
- await this.setState((r) => {
319
- const e = r.currentPropertyId;
320
- if (!e) return r;
321
- const i = r.properties[e];
322
- if (!i) return r;
323
- const s = i.favoritedUnits.includes(t) ? i.favoritedUnits.filter((a) => a !== t) : [...i.favoritedUnits, t];
301
+ await this.setState((e) => {
302
+ const r = e.currentPropertyId;
303
+ if (!r) return e;
304
+ const s = e.properties[r];
305
+ if (!s) return e;
306
+ const i = s.favoritedUnits.includes(t) ? s.favoritedUnits.filter((n) => n !== t) : [...s.favoritedUnits, t];
324
307
  return {
325
- ...r,
308
+ ...e,
326
309
  properties: {
327
- ...r.properties,
328
- [e]: {
329
- ...i,
330
- favoritedUnits: s
310
+ ...e.properties,
311
+ [r]: {
312
+ ...s,
313
+ favoritedUnits: i
331
314
  }
332
315
  }
333
316
  };
@@ -339,46 +322,46 @@ class A {
339
322
  * @param unitId - Identifier of the viewed unit.
340
323
  * @param slug - Property slug used to construct the URL.
341
324
  */
342
- async markUnitAsViewed(t, r) {
343
- const e = /* @__PURE__ */ new Date(), i = `${String(e.getMonth() + 1).padStart(
325
+ async markUnitAsViewed(t, e) {
326
+ const r = /* @__PURE__ */ new Date(), s = `${String(r.getMonth() + 1).padStart(
344
327
  2,
345
328
  "0"
346
- )}/${String(e.getDate()).padStart(2, "0")}`;
347
- await this.setState((n) => {
348
- const s = n.currentPropertyId;
349
- if (!s) return n;
350
- const a = n.properties[s];
351
- if (!a) return n;
352
- const u = [
353
- ...a.viewedUnits.filter((p) => p.unitId !== t),
354
- { unitId: t, viewedDate: i }
329
+ )}/${String(r.getDate()).padStart(2, "0")}`;
330
+ await this.setState((a) => {
331
+ const i = a.currentPropertyId;
332
+ if (!i) return a;
333
+ const n = a.properties[i];
334
+ if (!n) return a;
335
+ const o = [
336
+ ...n.viewedUnits.filter((p) => p.unitId !== t),
337
+ { unitId: t, viewedDate: s }
355
338
  ];
356
339
  return {
357
- ...n,
340
+ ...a,
358
341
  properties: {
359
- ...n.properties,
360
- [s]: {
361
- ...a,
362
- viewedUnits: u
342
+ ...a.properties,
343
+ [i]: {
344
+ ...n,
345
+ viewedUnits: o
363
346
  }
364
347
  }
365
348
  };
366
- }), typeof window < "u" && window.open(`//${r}`, "_blank");
349
+ }), typeof window < "u" && window.open(`//${e}`, "_blank");
367
350
  }
368
351
  /**
369
352
  * Stamps the current property with the moment the tour outreach occurred.
370
353
  */
371
354
  async setTourContactedOn() {
372
355
  await this.setState((t) => {
373
- const r = t.currentPropertyId;
374
- if (!r) return t;
375
- const e = t.properties[r];
376
- return e ? {
356
+ const e = t.currentPropertyId;
357
+ if (!e) return t;
358
+ const r = t.properties[e];
359
+ return r ? {
377
360
  ...t,
378
361
  properties: {
379
362
  ...t.properties,
380
- [r]: {
381
- ...e,
363
+ [e]: {
364
+ ...r,
382
365
  tourContactedOn: (/* @__PURE__ */ new Date()).toISOString()
383
366
  }
384
367
  }
@@ -391,9 +374,9 @@ class A {
391
374
  * @returns ISO string or null when no timestamp exists.
392
375
  */
393
376
  async getTourContactedOn() {
394
- var e;
395
- const t = await this.getState(), r = t.currentPropertyId;
396
- return r ? ((e = t.properties[r]) == null ? void 0 : e.tourContactedOn) ?? null : null;
377
+ var r;
378
+ const t = await this.getState(), e = t.currentPropertyId;
379
+ return e ? ((r = t.properties[e]) == null ? void 0 : r.tourContactedOn) ?? null : null;
397
380
  }
398
381
  /**
399
382
  * Persists questionnaire results captured for the current property.
@@ -401,20 +384,20 @@ class A {
401
384
  * @param results - Arbitrary questionnaire data.
402
385
  */
403
386
  async setQuestionnaireResults(t) {
404
- await this.setState((r) => {
405
- const e = r.currentPropertyId;
406
- if (!e) return r;
407
- const i = r.properties[e];
408
- return i ? {
409
- ...r,
387
+ await this.setState((e) => {
388
+ const r = e.currentPropertyId;
389
+ if (!r) return e;
390
+ const s = e.properties[r];
391
+ return s ? {
392
+ ...e,
410
393
  properties: {
411
- ...r.properties,
412
- [e]: {
413
- ...i,
394
+ ...e.properties,
395
+ [r]: {
396
+ ...s,
414
397
  questionnaireResults: t
415
398
  }
416
399
  }
417
- } : r;
400
+ } : e;
418
401
  });
419
402
  }
420
403
  /**
@@ -424,19 +407,19 @@ class A {
424
407
  * @param data - Contact preferences captured from the UI.
425
408
  */
426
409
  async setTourContactData(t) {
427
- const r = await this.waitForCurrentProperty();
428
- await this.setState((e) => {
429
- const i = e.properties[r];
430
- return i ? {
431
- ...e,
410
+ const e = await this.waitForCurrentProperty();
411
+ await this.setState((r) => {
412
+ const s = r.properties[e];
413
+ return s ? {
414
+ ...r,
432
415
  properties: {
433
- ...e.properties,
434
- [r]: {
435
- ...i,
416
+ ...r.properties,
417
+ [e]: {
418
+ ...s,
436
419
  tourContactData: t
437
420
  }
438
421
  }
439
- } : e;
422
+ } : r;
440
423
  });
441
424
  }
442
425
  // === FILTER OPERATIONS ===
@@ -446,9 +429,9 @@ class A {
446
429
  * @param filters - Partial filter payload to apply.
447
430
  */
448
431
  async setFilters(t) {
449
- await this.setState((r) => ({
450
- ...r,
451
- filters: { ...r.filters, ...t }
432
+ await this.setState((e) => ({
433
+ ...e,
434
+ filters: { ...e.filters, ...t }
452
435
  }));
453
436
  }
454
437
  /**
@@ -457,16 +440,16 @@ class A {
457
440
  * @param filters - Partial staging filter payload.
458
441
  */
459
442
  async setTempFilters(t) {
460
- await this.setState((r) => ({
461
- ...r,
462
- tempFilters: { ...r.tempFilters, ...t }
443
+ await this.setState((e) => ({
444
+ ...e,
445
+ tempFilters: { ...e.tempFilters, ...t }
463
446
  }));
464
447
  }
465
448
  /**
466
449
  * Resets the committed filters to their default values.
467
450
  */
468
451
  async setFiltersToDefault() {
469
- await this.setState((t) => ({ ...t, filters: w }));
452
+ await this.setState((t) => ({ ...t, filters: h }));
470
453
  }
471
454
  /**
472
455
  * Merges partial values into the API filters payload used for network requests.
@@ -474,9 +457,9 @@ class A {
474
457
  * @param filters - Partial query parameters to persist.
475
458
  */
476
459
  async setApiFilters(t) {
477
- await this.setState((r) => ({
478
- ...r,
479
- apiFilters: { ...r.apiFilters, ...t }
460
+ await this.setState((e) => ({
461
+ ...e,
462
+ apiFilters: { ...e.apiFilters, ...t }
480
463
  }));
481
464
  }
482
465
  /**
@@ -485,10 +468,10 @@ class A {
485
468
  * @param key - Filter key to mutate.
486
469
  * @param value - New value to assign.
487
470
  */
488
- async handleTempFilterChange(t, r) {
489
- await this.setState((e) => ({
490
- ...e,
491
- tempFilters: { ...e.tempFilters, [t]: r }
471
+ async handleTempFilterChange(t, e) {
472
+ await this.setState((r) => ({
473
+ ...r,
474
+ tempFilters: { ...r.tempFilters, [t]: e }
492
475
  }));
493
476
  }
494
477
  /**
@@ -496,16 +479,22 @@ class A {
496
479
  */
497
480
  async submitFilterUpdate() {
498
481
  await this.setState((t) => {
499
- const r = {
500
- ...t.apiFilters,
501
- availability: P(t.filters.availability),
502
- bedrooms: R(t.filters.bedrooms),
503
- cost: v(t.filters.cost),
504
- highlights: P(t.filters.highlights)
505
- };
482
+ const e = m(
483
+ {
484
+ ...t.filters,
485
+ limit: t.apiFilters.limit,
486
+ page: t.apiFilters.page,
487
+ sortBy: t.sortBy
488
+ },
489
+ {
490
+ defaultLimit: t.apiFilters.limit,
491
+ defaultPage: t.apiFilters.page,
492
+ defaultSort: t.sortBy
493
+ }
494
+ );
506
495
  return {
507
496
  ...t,
508
- apiFilters: r
497
+ apiFilters: e
509
498
  };
510
499
  });
511
500
  }
@@ -516,7 +505,7 @@ class A {
516
505
  * @param mode - Mode identifier to store.
517
506
  */
518
507
  async setResultsMode(t) {
519
- await this.setState((r) => ({ ...r, resultsMode: t }));
508
+ await this.setState((e) => ({ ...e, resultsMode: t }));
520
509
  }
521
510
  /**
522
511
  * Persists the currently selected sort option.
@@ -524,7 +513,7 @@ class A {
524
513
  * @param sortBy - Sort identifier.
525
514
  */
526
515
  async setSortBy(t) {
527
- await this.setState((r) => ({ ...r, sortBy: t }));
516
+ await this.setState((e) => ({ ...e, sortBy: t }));
528
517
  }
529
518
  // === QUESTIONNAIRE ===
530
519
  /**
@@ -533,12 +522,12 @@ class A {
533
522
  * @param name - Questionnaire identifier.
534
523
  * @param values - Selected option values.
535
524
  */
536
- async setResolvedQuestionnaireValues(t, r) {
537
- await this.setState((e) => ({
538
- ...e,
525
+ async setResolvedQuestionnaireValues(t, e) {
526
+ await this.setState((r) => ({
527
+ ...r,
539
528
  resolvedQuestionnaireValues: {
540
- ...e.resolvedQuestionnaireValues,
541
- [t]: r
529
+ ...r.resolvedQuestionnaireValues,
530
+ [t]: e
542
531
  }
543
532
  }));
544
533
  }
@@ -550,11 +539,11 @@ class A {
550
539
  * @returns Favorite flag and last viewed date.
551
540
  */
552
541
  async getUnitState(t) {
553
- var i;
554
- const r = await this.getState(), e = r.currentPropertyId ? r.properties[r.currentPropertyId] : null;
542
+ var s;
543
+ const e = await this.getState(), r = e.currentPropertyId ? e.properties[e.currentPropertyId] : null;
555
544
  return {
556
- isFavorite: (e == null ? void 0 : e.favoritedUnits.includes(t)) ?? !1,
557
- viewedDate: ((i = e == null ? void 0 : e.viewedUnits.find((n) => n.unitId === t)) == null ? void 0 : i.viewedDate) ?? ""
545
+ isFavorite: (r == null ? void 0 : r.favoritedUnits.includes(t)) ?? !1,
546
+ viewedDate: ((s = r == null ? void 0 : r.viewedUnits.find((a) => a.unitId === t)) == null ? void 0 : s.viewedDate) ?? ""
558
547
  };
559
548
  }
560
549
  /**
@@ -582,8 +571,8 @@ class A {
582
571
  * @returns Property state or null when unavailable.
583
572
  */
584
573
  async getPropertyData(t) {
585
- const r = await this.getState(), e = t == null ? r.currentPropertyId : String(t);
586
- return e ? r.properties[e] ?? null : null;
574
+ const e = await this.getState(), r = t == null ? e.currentPropertyId : String(t);
575
+ return r ? e.properties[r] ?? null : null;
587
576
  }
588
577
  /**
589
578
  * Reads and returns the full validated unified store state.
@@ -595,13 +584,13 @@ class A {
595
584
  * Hydrates the store with the default scaffold when no data has been persisted yet.
596
585
  */
597
586
  async initialize() {
598
- await this.setState((t) => ({ ...S, ...t }));
587
+ await this.setState((t) => ({ ...y, ...t }));
599
588
  }
600
589
  }
601
- const $ = new A();
590
+ const b = new F();
602
591
  export {
603
- A as Store,
604
- A as UnifiedStore,
605
- $ as store
592
+ F as Store,
593
+ F as UnifiedStore,
594
+ b as store
606
595
  };
607
596
  //# sourceMappingURL=store.mjs.map