@superbright/indexeddb-orm 0.1.4 → 0.1.5
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 +16 -14
- package/dist/adapters/dexie.d.ts +14 -0
- package/dist/adapters/structured-store.d.ts +44 -0
- package/dist/adapters/zustand-store.d.ts +54 -0
- package/dist/api/favorites.d.ts +4 -0
- package/dist/api/properties.d.ts +22 -0
- package/dist/api/users.d.ts +5 -0
- package/dist/db.d.ts +15 -0
- package/dist/debug.d.ts +2 -0
- package/dist/errors.d.ts +8 -0
- package/dist/features/units/transformers.d.ts +75 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.mjs +261 -352
- package/dist/index.mjs.map +1 -1
- package/dist/schema.d.ts +2880 -0
- package/dist/storage.d.ts +14 -0
- package/dist/stores/store.d.ts +42 -0
- package/dist/units/favorites.d.ts +7 -0
- package/dist/validation.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { z as n } from "zod";
|
|
2
2
|
import nt from "dexie";
|
|
3
|
-
class
|
|
3
|
+
class at extends Error {
|
|
4
4
|
constructor(t, e) {
|
|
5
5
|
super(t), this.detail = e, this.name = "SchemaMismatchError";
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
class
|
|
8
|
+
class it extends Error {
|
|
9
9
|
constructor(t, e) {
|
|
10
10
|
super(t), this.detail = e, this.name = "OpenDBError";
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const F = 1, S = n.object({
|
|
14
14
|
uuid: n.string().uuid(),
|
|
15
15
|
// stored as ISO string; include to match ensureUser()
|
|
16
16
|
createdAt: n.string().datetime().optional()
|
|
17
|
-
}),
|
|
17
|
+
}), st = n.object({
|
|
18
18
|
isFavorite: n.boolean().optional(),
|
|
19
19
|
viewedDate: n.string().optional()
|
|
20
|
-
}),
|
|
20
|
+
}), ot = st, R = n.union([
|
|
21
21
|
n.string(),
|
|
22
22
|
n.number(),
|
|
23
23
|
n.boolean(),
|
|
24
24
|
n.record(n.unknown())
|
|
25
|
-
]),
|
|
25
|
+
]), lt = n.union([
|
|
26
26
|
R,
|
|
27
27
|
n.array(R)
|
|
28
|
-
]),
|
|
29
|
-
availability:
|
|
28
|
+
]), D = n.object({
|
|
29
|
+
availability: lt.nullable().optional(),
|
|
30
30
|
bedrooms: n.union([n.array(R), n.null()]).optional(),
|
|
31
31
|
cost: n.number().nullable().optional(),
|
|
32
32
|
highlights: n.array(R).optional()
|
|
33
|
-
}),
|
|
33
|
+
}), q = n.object({
|
|
34
34
|
limit: n.number().default(10),
|
|
35
35
|
page: n.number().default(1),
|
|
36
36
|
availability: n.array(n.string()).optional(),
|
|
37
37
|
bedrooms: n.array(n.number()).optional(),
|
|
38
38
|
cost: n.number().nullable().optional(),
|
|
39
39
|
highlights: n.array(n.string()).optional()
|
|
40
|
-
}),
|
|
41
|
-
data: n.record(
|
|
42
|
-
filters:
|
|
43
|
-
tempFilters:
|
|
44
|
-
apiFilters:
|
|
45
|
-
resultsMode:
|
|
40
|
+
}), J = n.enum(["all", "bestFit", "closestMatch", "favorites", "loading"]), G = n.enum(["relevance", "newest", "priceLowToHigh", "priceHighToLow"]), Tt = n.object({
|
|
41
|
+
data: n.record(ot),
|
|
42
|
+
filters: D,
|
|
43
|
+
tempFilters: D,
|
|
44
|
+
apiFilters: q,
|
|
45
|
+
resultsMode: J,
|
|
46
46
|
propertySlug: n.string().nullable(),
|
|
47
47
|
resolvedQuestionnaireValues: n.record(n.array(n.string())),
|
|
48
|
-
sortBy:
|
|
48
|
+
sortBy: G
|
|
49
49
|
}), b = n.object({
|
|
50
50
|
id: n.union([n.number().int(), n.string()]).optional(),
|
|
51
51
|
title: n.string(),
|
|
@@ -117,25 +117,25 @@ const I = 1, m = n.object({
|
|
|
117
117
|
floorPlans: n.array(n.unknown()).optional(),
|
|
118
118
|
createdAt: n.string().datetime().optional(),
|
|
119
119
|
updatedAt: n.string().datetime().optional()
|
|
120
|
-
}),
|
|
120
|
+
}), ut = n.object({
|
|
121
121
|
unitId: n.string(),
|
|
122
122
|
viewedDate: n.string()
|
|
123
|
-
}),
|
|
123
|
+
}), ct = n.object({
|
|
124
124
|
timezone: n.string().optional(),
|
|
125
125
|
favouriteUnits: n.array(n.coerce.string()).optional(),
|
|
126
126
|
preferences: n.record(n.unknown()).optional()
|
|
127
|
-
}),
|
|
127
|
+
}), A = n.object({
|
|
128
128
|
id: n.coerce.string(),
|
|
129
129
|
slug: n.string(),
|
|
130
130
|
favoritedUnits: n.array(n.string()),
|
|
131
131
|
tourContactedOn: n.string().nullable(),
|
|
132
|
-
viewedUnits: n.array(
|
|
132
|
+
viewedUnits: n.array(ut),
|
|
133
133
|
questionnaireResults: n.unknown().nullable().optional(),
|
|
134
|
-
tourContactData:
|
|
134
|
+
tourContactData: ct.nullable().optional(),
|
|
135
135
|
// Full property payload persisted alongside per-property state
|
|
136
136
|
data: v.optional()
|
|
137
|
-
}),
|
|
138
|
-
data: n.record(
|
|
137
|
+
}), C = n.object({
|
|
138
|
+
data: n.record(A),
|
|
139
139
|
propertySlug: n.string().nullable(),
|
|
140
140
|
propertyId: n.string().nullable(),
|
|
141
141
|
hasPreviouslySearched: n.array(n.string())
|
|
@@ -144,73 +144,73 @@ const I = 1, m = n.object({
|
|
|
144
144
|
userId: n.number().int(),
|
|
145
145
|
unitId: n.number().int(),
|
|
146
146
|
createdAt: n.string().datetime()
|
|
147
|
-
}),
|
|
147
|
+
}), j = n.object({
|
|
148
148
|
// per-property favorites are stored under a KV key, so propertyId is implicit
|
|
149
149
|
unitIds: n.array(n.string()),
|
|
150
150
|
updatedAt: n.string().datetime()
|
|
151
|
-
}),
|
|
151
|
+
}), O = n.object({
|
|
152
152
|
// Property-related data
|
|
153
|
-
properties: n.record(
|
|
153
|
+
properties: n.record(A),
|
|
154
154
|
currentPropertyId: n.string().nullable(),
|
|
155
155
|
currentPropertySlug: n.string().nullable(),
|
|
156
156
|
hasPreviouslySearched: n.array(n.string()),
|
|
157
157
|
// App-level data
|
|
158
158
|
unitResults: n.array(b),
|
|
159
|
-
filters:
|
|
160
|
-
tempFilters:
|
|
161
|
-
apiFilters:
|
|
162
|
-
resultsMode:
|
|
159
|
+
filters: D,
|
|
160
|
+
tempFilters: D,
|
|
161
|
+
apiFilters: q,
|
|
162
|
+
resultsMode: J,
|
|
163
163
|
resolvedQuestionnaireValues: n.record(n.array(n.string())),
|
|
164
|
-
sortBy:
|
|
164
|
+
sortBy: G
|
|
165
165
|
});
|
|
166
|
-
class
|
|
166
|
+
class N extends nt {
|
|
167
167
|
constructor(t = "inresi-orm") {
|
|
168
|
-
super(t), this.version(
|
|
168
|
+
super(t), this.version(F).stores({
|
|
169
169
|
users: "uuid",
|
|
170
170
|
kv: "key"
|
|
171
171
|
}), this.users = this.table("users"), this.kv = this.table("kv");
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
let _ = "strict",
|
|
175
|
-
function
|
|
176
|
-
r.mode && (_ = r.mode),
|
|
174
|
+
let _ = "strict", I;
|
|
175
|
+
function dt(r) {
|
|
176
|
+
r.mode && (_ = r.mode), I = r.onIssue;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function w(r, t, e) {
|
|
179
179
|
const a = r.safeParse(t);
|
|
180
180
|
if (a.success) return a.data;
|
|
181
181
|
const s = a.error.flatten();
|
|
182
|
-
if (
|
|
183
|
-
throw new
|
|
182
|
+
if (I == null || I(e, s), _ === "strict")
|
|
183
|
+
throw new at(`ORM schema mismatch in ${e}`, s);
|
|
184
184
|
return _ === "warn" && console.warn(`ORM schema mismatch in ${e}`, s), null;
|
|
185
185
|
}
|
|
186
|
-
const
|
|
187
|
-
let
|
|
188
|
-
const
|
|
189
|
-
function
|
|
186
|
+
const pt = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, T = "manifest", yt = n.object({ schemaVersion: n.number().int() });
|
|
187
|
+
let h = null, m = null;
|
|
188
|
+
const Q = Symbol("validationInstalled");
|
|
189
|
+
function M(r, t) {
|
|
190
190
|
const e = r;
|
|
191
|
-
if (e[
|
|
192
|
-
if (e[
|
|
193
|
-
i.hook("creating", (u,
|
|
194
|
-
const y =
|
|
191
|
+
if (e[Q]) return;
|
|
192
|
+
if (e[Q] = !0, ((i, o, l) => {
|
|
193
|
+
i.hook("creating", (u, c) => {
|
|
194
|
+
const y = w(o, c, `${l}.creating`);
|
|
195
195
|
if (!y) throw new Error(`Rejected invalid ${l} on create`);
|
|
196
196
|
return y;
|
|
197
|
-
}), i.hook("updating", (u,
|
|
197
|
+
}), i.hook("updating", (u, c, y) => {
|
|
198
198
|
const p = { ...y, ...u };
|
|
199
|
-
return
|
|
199
|
+
return w(o, p, `${l}.updating`) ? u : {};
|
|
200
200
|
});
|
|
201
|
-
})(r.users,
|
|
201
|
+
})(r.users, S, "users"), (t == null ? void 0 : t.validateReads) ?? !0) {
|
|
202
202
|
const i = (t == null ? void 0 : t.dropInvalidOnRead) ?? !0;
|
|
203
|
-
((l, u,
|
|
203
|
+
((l, u, c) => {
|
|
204
204
|
l.hook("reading", (y) => {
|
|
205
|
-
const p =
|
|
205
|
+
const p = w(u, y, `${c}.reading`);
|
|
206
206
|
return p || (i ? void 0 : y);
|
|
207
207
|
});
|
|
208
|
-
})(r.users,
|
|
208
|
+
})(r.users, S, "users");
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
function ft() {
|
|
212
212
|
try {
|
|
213
|
-
if (typeof import.meta < "u" &&
|
|
213
|
+
if (typeof import.meta < "u" && pt)
|
|
214
214
|
return !1;
|
|
215
215
|
} catch {
|
|
216
216
|
}
|
|
@@ -221,19 +221,19 @@ function ft() {
|
|
|
221
221
|
}
|
|
222
222
|
return !1;
|
|
223
223
|
}
|
|
224
|
-
async function
|
|
225
|
-
if (
|
|
226
|
-
if (
|
|
224
|
+
async function g(r = {}) {
|
|
225
|
+
if (h) return h;
|
|
226
|
+
if (m) return m;
|
|
227
227
|
const t = r.dbName ?? "inresi-orm";
|
|
228
|
-
return
|
|
228
|
+
return m = (async () => {
|
|
229
229
|
var e, a, s, i;
|
|
230
230
|
try {
|
|
231
231
|
const o = ft() ? "warn" : "strict";
|
|
232
|
-
|
|
232
|
+
dt({
|
|
233
233
|
mode: ((e = r.validation) == null ? void 0 : e.mode) ?? o,
|
|
234
234
|
onIssue: (a = r.validation) == null ? void 0 : a.onIssue
|
|
235
235
|
});
|
|
236
|
-
const l = new
|
|
236
|
+
const l = new N(t);
|
|
237
237
|
l.on("versionchange", () => {
|
|
238
238
|
var p;
|
|
239
239
|
try {
|
|
@@ -245,51 +245,51 @@ async function f(r = {}) {
|
|
|
245
245
|
var p;
|
|
246
246
|
(p = r.onReset) == null || p.call(r, "blocked");
|
|
247
247
|
}), await l.open();
|
|
248
|
-
const u = await l.kv.get(
|
|
249
|
-
if (!
|
|
248
|
+
const u = await l.kv.get(T), c = (u == null ? void 0 : u.value) ?? null;
|
|
249
|
+
if (!c)
|
|
250
250
|
return await l.transaction("rw", l.kv, async () => {
|
|
251
251
|
await l.kv.put({
|
|
252
|
-
key:
|
|
253
|
-
value: { schemaVersion:
|
|
252
|
+
key: T,
|
|
253
|
+
value: { schemaVersion: F }
|
|
254
254
|
});
|
|
255
|
-
}),
|
|
256
|
-
const y =
|
|
257
|
-
if (!y.success || y.data.schemaVersion !==
|
|
255
|
+
}), M(l, r.validation), h = l, l;
|
|
256
|
+
const y = yt.safeParse(c);
|
|
257
|
+
if (!y.success || y.data.schemaVersion !== F) {
|
|
258
258
|
await l.delete();
|
|
259
|
-
const p = new
|
|
259
|
+
const p = new N(t);
|
|
260
260
|
return p.on("versionchange", () => {
|
|
261
|
-
var
|
|
261
|
+
var f;
|
|
262
262
|
try {
|
|
263
263
|
p.close();
|
|
264
264
|
} finally {
|
|
265
|
-
(
|
|
265
|
+
(f = r.onReset) == null || f.call(r, "versionchange");
|
|
266
266
|
}
|
|
267
267
|
}), p.on("blocked", () => {
|
|
268
|
-
var
|
|
269
|
-
(
|
|
268
|
+
var f;
|
|
269
|
+
(f = r.onReset) == null || f.call(r, "blocked");
|
|
270
270
|
}), await p.open(), await p.kv.put({
|
|
271
|
-
key:
|
|
272
|
-
value: { schemaVersion:
|
|
273
|
-
}),
|
|
271
|
+
key: T,
|
|
272
|
+
value: { schemaVersion: F }
|
|
273
|
+
}), M(p, r.validation), (s = r.onReset) == null || s.call(r, "incompatible"), h = p, p;
|
|
274
274
|
}
|
|
275
|
-
return
|
|
275
|
+
return M(l, r.validation), h = l, l;
|
|
276
276
|
} catch (o) {
|
|
277
|
-
throw (i = r.onError) == null || i.call(r, o), new
|
|
277
|
+
throw (i = r.onError) == null || i.call(r, o), new it("Failed to open IndexedDB", o);
|
|
278
278
|
} finally {
|
|
279
|
-
|
|
279
|
+
m = null;
|
|
280
280
|
}
|
|
281
|
-
})(),
|
|
281
|
+
})(), m;
|
|
282
282
|
}
|
|
283
283
|
async function Vt(r) {
|
|
284
284
|
const t = r ?? "inresi-orm";
|
|
285
|
-
if (
|
|
285
|
+
if (h)
|
|
286
286
|
try {
|
|
287
|
-
await
|
|
287
|
+
await h.close();
|
|
288
288
|
} catch {
|
|
289
289
|
}
|
|
290
|
-
await new
|
|
290
|
+
await new N(t).delete(), h = null;
|
|
291
291
|
}
|
|
292
|
-
const P = "user",
|
|
292
|
+
const P = "user", gt = () => {
|
|
293
293
|
var r;
|
|
294
294
|
return typeof ((r = globalThis.crypto) == null ? void 0 : r.randomUUID) == "function" ? globalThis.crypto.randomUUID() : (() => {
|
|
295
295
|
var a, s;
|
|
@@ -298,26 +298,26 @@ const P = "user", ht = () => {
|
|
|
298
298
|
const e = [...t].map((i) => i.toString(16).padStart(2, "0")).join("");
|
|
299
299
|
return `${e.slice(0, 8)}-${e.slice(8, 12)}-${e.slice(12, 16)}-${e.slice(16, 20)}-${e.slice(20)}`;
|
|
300
300
|
})();
|
|
301
|
-
},
|
|
301
|
+
}, E = (r) => {
|
|
302
302
|
var t, e;
|
|
303
303
|
return ((t = r == null ? void 0 : r.value) == null ? void 0 : t.useruuid) ?? ((e = r == null ? void 0 : r.value) == null ? void 0 : e.uuid);
|
|
304
304
|
};
|
|
305
|
-
async function
|
|
306
|
-
const t = await
|
|
305
|
+
async function B(r = gt) {
|
|
306
|
+
const t = await g(), e = E(await t.kv.get(P));
|
|
307
307
|
if (e) {
|
|
308
308
|
const a = await t.users.get(e);
|
|
309
|
-
if (a) return
|
|
309
|
+
if (a) return S.parse(a);
|
|
310
310
|
}
|
|
311
311
|
try {
|
|
312
312
|
return await t.transaction("rw", t.kv, t.users, async () => {
|
|
313
|
-
const a =
|
|
313
|
+
const a = E(await t.kv.get(P));
|
|
314
314
|
if (a) {
|
|
315
315
|
const o = await t.users.get(a);
|
|
316
|
-
if (o) return
|
|
316
|
+
if (o) return S.parse(o);
|
|
317
317
|
}
|
|
318
318
|
const s = r();
|
|
319
319
|
await t.kv.add({ key: P, value: { useruuid: s } });
|
|
320
|
-
const i =
|
|
320
|
+
const i = S.parse({
|
|
321
321
|
uuid: s,
|
|
322
322
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
323
323
|
});
|
|
@@ -325,18 +325,18 @@ async function z(r = ht) {
|
|
|
325
325
|
});
|
|
326
326
|
} catch (a) {
|
|
327
327
|
if ((a == null ? void 0 : a.name) === "ConstraintError") {
|
|
328
|
-
const s =
|
|
328
|
+
const s = E(await t.kv.get(P));
|
|
329
329
|
if (s) {
|
|
330
330
|
const i = await t.users.get(s);
|
|
331
|
-
if (i) return
|
|
331
|
+
if (i) return S.parse(i);
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
334
|
throw a;
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
const $t = async (r) => (await
|
|
337
|
+
const $t = async (r) => (await B(r)).uuid;
|
|
338
338
|
async function wt() {
|
|
339
|
-
const r = await
|
|
339
|
+
const r = await g(), t = {};
|
|
340
340
|
for (const e of r.tables)
|
|
341
341
|
t[e.name] = await e.toArray();
|
|
342
342
|
return t;
|
|
@@ -347,22 +347,22 @@ async function jt(r = "inresi-orm-export.json") {
|
|
|
347
347
|
const t = await wt(), e = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), a = document.createElement("a");
|
|
348
348
|
a.href = URL.createObjectURL(e), a.download = r, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(a.href);
|
|
349
349
|
}
|
|
350
|
-
async function
|
|
351
|
-
const e = await (await
|
|
350
|
+
async function K(r) {
|
|
351
|
+
const e = await (await g()).kv.get(r);
|
|
352
352
|
return (e == null ? void 0 : e.value) ?? null;
|
|
353
353
|
}
|
|
354
|
-
async function
|
|
355
|
-
await (await
|
|
354
|
+
async function W(r, t) {
|
|
355
|
+
await (await g()).kv.put({ key: r, value: t });
|
|
356
356
|
}
|
|
357
357
|
async function Nt(r) {
|
|
358
|
-
await (await
|
|
358
|
+
await (await g()).kv.delete(r);
|
|
359
359
|
}
|
|
360
|
-
function
|
|
360
|
+
function _t(r) {
|
|
361
361
|
const t = /* @__PURE__ */ new Map(), e = (r == null ? void 0 : r.prefix) ?? "", a = (s) => `${e}${s}`;
|
|
362
362
|
return {
|
|
363
363
|
async getItem(s) {
|
|
364
364
|
try {
|
|
365
|
-
const o = await (await
|
|
365
|
+
const o = await (await g()).kv.get(a(s));
|
|
366
366
|
return o ? JSON.stringify(o.value) : null;
|
|
367
367
|
} catch (i) {
|
|
368
368
|
if (r != null && r.fallbackToMemory) return t.get(a(s)) ?? null;
|
|
@@ -371,7 +371,7 @@ function xt(r) {
|
|
|
371
371
|
},
|
|
372
372
|
async setItem(s, i) {
|
|
373
373
|
try {
|
|
374
|
-
await (await
|
|
374
|
+
await (await g()).kv.put({ key: a(s), value: JSON.parse(i) });
|
|
375
375
|
} catch (o) {
|
|
376
376
|
if (r != null && r.fallbackToMemory) {
|
|
377
377
|
t.set(a(s), i);
|
|
@@ -382,7 +382,7 @@ function xt(r) {
|
|
|
382
382
|
},
|
|
383
383
|
async removeItem(s) {
|
|
384
384
|
try {
|
|
385
|
-
await (await
|
|
385
|
+
await (await g()).kv.delete(a(s));
|
|
386
386
|
} catch (i) {
|
|
387
387
|
if (r != null && r.fallbackToMemory) {
|
|
388
388
|
t.delete(a(s));
|
|
@@ -393,81 +393,62 @@ function xt(r) {
|
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
|
-
const
|
|
397
|
-
async function
|
|
398
|
-
const t = await
|
|
396
|
+
const Y = (r, t) => `favorites:${r}:${t}`;
|
|
397
|
+
async function z(r) {
|
|
398
|
+
const t = await g(), { uuid: e } = await B(), a = Y(e, String(r)), s = await t.kv.get(a), i = s ? j.safeParse(s.value) : null;
|
|
399
399
|
return i != null && i.success ? i.data.unitIds : [];
|
|
400
400
|
}
|
|
401
|
-
async function
|
|
402
|
-
const a = await
|
|
401
|
+
async function Z(r, t, e) {
|
|
402
|
+
const a = await g(), { uuid: s } = await B(), i = Y(s, String(r));
|
|
403
403
|
return a.transaction("rw", a.kv, async () => {
|
|
404
|
-
const o = await a.kv.get(i), l = o &&
|
|
404
|
+
const o = await a.kv.get(i), l = o && j.safeParse(o.value).success ? o.value : { unitIds: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, u = new Set(l.unitIds);
|
|
405
405
|
e ? u.add(t) : u.delete(t);
|
|
406
|
-
const
|
|
406
|
+
const c = {
|
|
407
407
|
unitIds: [...u],
|
|
408
408
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
409
|
-
}, y =
|
|
409
|
+
}, y = j.parse(c);
|
|
410
410
|
return await a.kv.put({ key: i, value: y }), y.unitIds;
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
|
-
async function
|
|
414
|
-
const a = !(await
|
|
415
|
-
return
|
|
413
|
+
async function ht(r, t) {
|
|
414
|
+
const a = !(await z(r)).includes(t);
|
|
415
|
+
return Z(r, t, a);
|
|
416
416
|
}
|
|
417
417
|
async function St(r, t) {
|
|
418
|
-
return (await
|
|
418
|
+
return (await z(r)).includes(t);
|
|
419
419
|
}
|
|
420
|
-
const
|
|
420
|
+
const V = {
|
|
421
421
|
data: {},
|
|
422
422
|
propertySlug: null,
|
|
423
423
|
propertyId: null,
|
|
424
424
|
hasPreviouslySearched: []
|
|
425
425
|
};
|
|
426
|
-
class
|
|
426
|
+
class mt {
|
|
427
427
|
async getState() {
|
|
428
|
-
const t = await
|
|
429
|
-
if (!t) return
|
|
428
|
+
const t = await K("property");
|
|
429
|
+
if (!t) return V;
|
|
430
430
|
const e = {
|
|
431
431
|
...t,
|
|
432
432
|
propertyId: t.propertyId == null ? null : String(t.propertyId),
|
|
433
433
|
propertySlug: t.propertySlug ?? null,
|
|
434
434
|
hasPreviouslySearched: Array.isArray(t.hasPreviouslySearched) ? t.hasPreviouslySearched.map(String) : []
|
|
435
|
-
}, a =
|
|
435
|
+
}, a = C.safeParse(e);
|
|
436
436
|
if (a.success) return a.data;
|
|
437
|
-
const s = Object.entries(e.data ?? {}).reduce((l, [u,
|
|
438
|
-
const y =
|
|
437
|
+
const s = Object.entries(e.data ?? {}).reduce((l, [u, c]) => {
|
|
438
|
+
const y = A.safeParse(c);
|
|
439
439
|
return y.success && (l[u] = y.data), l;
|
|
440
440
|
}, {}), i = {
|
|
441
|
-
|
|
441
|
+
...V,
|
|
442
442
|
...e,
|
|
443
443
|
data: s
|
|
444
|
-
}, o =
|
|
445
|
-
return o.success ? o.data :
|
|
444
|
+
}, o = C.safeParse(i);
|
|
445
|
+
return o.success ? o.data : V;
|
|
446
446
|
}
|
|
447
447
|
async setState(t) {
|
|
448
|
-
const e = await this.getState(), a = t(e), s =
|
|
449
|
-
await
|
|
450
|
-
}
|
|
451
|
-
// Basic state operations
|
|
452
|
-
async setData(t) {
|
|
453
|
-
await this.setState((e) => ({ ...e, data: t }));
|
|
454
|
-
}
|
|
455
|
-
async setPropertySlug(t) {
|
|
456
|
-
await this.setState((e) => ({ ...e, propertySlug: t }));
|
|
457
|
-
}
|
|
458
|
-
async setPropertyId(t) {
|
|
459
|
-
await this.setState((e) => ({ ...e, propertyId: String(t) }));
|
|
460
|
-
}
|
|
461
|
-
async removeData(t) {
|
|
462
|
-
const e = String(t);
|
|
463
|
-
await this.setState((a) => ({
|
|
464
|
-
...a,
|
|
465
|
-
data: Object.entries(a.data).filter(([s]) => s !== e).reduce((s, [i, o]) => ({ ...s, [i]: o }), {})
|
|
466
|
-
}));
|
|
467
|
-
}
|
|
468
|
-
async clearData() {
|
|
469
|
-
await this.setState((t) => ({ ...t, data: {} }));
|
|
448
|
+
const e = await this.getState(), a = t(e), s = C.parse(a);
|
|
449
|
+
await W("property", s);
|
|
470
450
|
}
|
|
451
|
+
// Basic state operations (legacy direct setters removed in vNext)
|
|
471
452
|
async setHasPreviouslySearched(t) {
|
|
472
453
|
await this.setState((e) => ({
|
|
473
454
|
...e,
|
|
@@ -564,7 +545,7 @@ class vt {
|
|
|
564
545
|
if (!l) return i;
|
|
565
546
|
const u = [
|
|
566
547
|
// Remove existing entry if it exists
|
|
567
|
-
...l.viewedUnits.filter((
|
|
548
|
+
...l.viewedUnits.filter((c) => c.unitId !== t),
|
|
568
549
|
// Add updated one
|
|
569
550
|
{
|
|
570
551
|
unitId: t,
|
|
@@ -625,12 +606,12 @@ class vt {
|
|
|
625
606
|
});
|
|
626
607
|
}
|
|
627
608
|
}
|
|
628
|
-
const
|
|
609
|
+
const xt = new mt(), x = {
|
|
629
610
|
availability: void 0,
|
|
630
611
|
bedrooms: void 0,
|
|
631
612
|
cost: void 0,
|
|
632
613
|
highlights: void 0
|
|
633
|
-
},
|
|
614
|
+
}, U = {
|
|
634
615
|
// Property data
|
|
635
616
|
properties: {},
|
|
636
617
|
currentPropertyId: null,
|
|
@@ -638,8 +619,8 @@ const _t = new vt(), B = {
|
|
|
638
619
|
hasPreviouslySearched: [],
|
|
639
620
|
// App data
|
|
640
621
|
unitResults: [],
|
|
641
|
-
filters:
|
|
642
|
-
tempFilters:
|
|
622
|
+
filters: x,
|
|
623
|
+
tempFilters: x,
|
|
643
624
|
apiFilters: {
|
|
644
625
|
limit: 10,
|
|
645
626
|
page: 1
|
|
@@ -647,7 +628,7 @@ const _t = new vt(), B = {
|
|
|
647
628
|
resultsMode: "all",
|
|
648
629
|
resolvedQuestionnaireValues: {},
|
|
649
630
|
sortBy: "relevance"
|
|
650
|
-
},
|
|
631
|
+
}, vt = (r) => r == null ? [] : Array.isArray(r) ? r : [r], X = (r) => vt(r).flatMap((t) => {
|
|
651
632
|
if (t == null) return [];
|
|
652
633
|
if (Array.isArray(t)) return t;
|
|
653
634
|
if (typeof t == "object" && "value" in t) {
|
|
@@ -655,49 +636,49 @@ const _t = new vt(), B = {
|
|
|
655
636
|
return Array.isArray(e) ? e : e != null ? [e] : [];
|
|
656
637
|
}
|
|
657
638
|
return [t];
|
|
658
|
-
}),
|
|
639
|
+
}), H = (r) => X(r).flatMap((t) => Array.isArray(t) ? t : [t]).map((t) => String(t)).map((t) => t.trim()).filter((t) => t.length > 0), bt = (r) => X(r).map((t) => {
|
|
659
640
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
660
641
|
const e = Number(t);
|
|
661
642
|
return Number.isFinite(e) ? e : null;
|
|
662
|
-
}).filter((t) => t !== null),
|
|
643
|
+
}).filter((t) => t !== null), tt = (r) => {
|
|
663
644
|
if (r == null) return null;
|
|
664
645
|
if (typeof r == "number") return Number.isFinite(r) ? r : null;
|
|
665
646
|
if (typeof r == "object" && "value" in r)
|
|
666
|
-
return
|
|
647
|
+
return tt(r.value);
|
|
667
648
|
const t = Number(r);
|
|
668
649
|
return Number.isFinite(t) ? t : null;
|
|
669
650
|
};
|
|
670
651
|
class Pt {
|
|
671
652
|
async getState() {
|
|
672
|
-
const t = await
|
|
653
|
+
const t = await K("app");
|
|
673
654
|
if (!t)
|
|
674
|
-
return
|
|
655
|
+
return U;
|
|
675
656
|
const e = {
|
|
676
|
-
...
|
|
657
|
+
...U,
|
|
677
658
|
...t,
|
|
678
659
|
properties: t.properties ?? {},
|
|
679
660
|
unitResults: t.unitResults ?? [],
|
|
680
661
|
currentPropertyId: t.currentPropertyId == null ? null : String(t.currentPropertyId),
|
|
681
662
|
currentPropertySlug: t.currentPropertySlug ?? null,
|
|
682
663
|
hasPreviouslySearched: Array.isArray(t.hasPreviouslySearched) ? t.hasPreviouslySearched.map(String) : []
|
|
683
|
-
}, a =
|
|
664
|
+
}, a = O.safeParse(e);
|
|
684
665
|
if (a.success) return a.data;
|
|
685
|
-
const s = Object.entries(e.properties ?? {}).reduce((
|
|
686
|
-
const
|
|
687
|
-
return
|
|
688
|
-
}, {}), o = (Array.isArray(e.unitResults) ? e.unitResults : e.unitResults && typeof e.unitResults == "object" ? Object.values(e.unitResults) : []).reduce((
|
|
666
|
+
const s = Object.entries(e.properties ?? {}).reduce((c, [y, p]) => {
|
|
667
|
+
const f = A.safeParse(p);
|
|
668
|
+
return f.success && (c[y] = f.data), c;
|
|
669
|
+
}, {}), o = (Array.isArray(e.unitResults) ? e.unitResults : e.unitResults && typeof e.unitResults == "object" ? Object.values(e.unitResults) : []).reduce((c, y) => {
|
|
689
670
|
const p = b.safeParse(y);
|
|
690
|
-
return p.success &&
|
|
671
|
+
return p.success && c.push(p.data), c;
|
|
691
672
|
}, []), l = {
|
|
692
673
|
...e,
|
|
693
674
|
properties: s,
|
|
694
675
|
unitResults: o
|
|
695
|
-
}, u =
|
|
696
|
-
return u.success ? u.data :
|
|
676
|
+
}, u = O.safeParse(l);
|
|
677
|
+
return u.success ? u.data : U;
|
|
697
678
|
}
|
|
698
679
|
async setState(t) {
|
|
699
|
-
const e = await this.getState(), a = t(e), s =
|
|
700
|
-
await
|
|
680
|
+
const e = await this.getState(), a = t(e), s = O.parse(a);
|
|
681
|
+
await W("app", s);
|
|
701
682
|
}
|
|
702
683
|
// === PROPERTY OPERATIONS ===
|
|
703
684
|
async initializeProperty(t, e) {
|
|
@@ -726,10 +707,9 @@ class Pt {
|
|
|
726
707
|
}
|
|
727
708
|
// === UNIT RESULTS CACHE ===
|
|
728
709
|
async setUnitResults(t, e) {
|
|
729
|
-
console.log(t);
|
|
730
710
|
const a = e ?? b, s = [];
|
|
731
711
|
(Array.isArray(t) ? t : t && typeof t == "object" ? Object.values(t) : []).forEach((o, l) => {
|
|
732
|
-
const u =
|
|
712
|
+
const u = w(a, o, `unitResults[${l}]`);
|
|
733
713
|
u && s.push(u);
|
|
734
714
|
}), await this.setState((o) => ({
|
|
735
715
|
...o,
|
|
@@ -748,7 +728,7 @@ class Pt {
|
|
|
748
728
|
await this.setState((o) => {
|
|
749
729
|
const l = o.properties[s];
|
|
750
730
|
if (!l) return o;
|
|
751
|
-
const u =
|
|
731
|
+
const u = w(i, e, `properties.${s}.data`);
|
|
752
732
|
return u ? {
|
|
753
733
|
...o,
|
|
754
734
|
properties: {
|
|
@@ -768,25 +748,25 @@ class Pt {
|
|
|
768
748
|
if (!l) return o;
|
|
769
749
|
const u = l.data;
|
|
770
750
|
if (!u) {
|
|
771
|
-
const
|
|
772
|
-
return
|
|
751
|
+
const f = w(i, e, `properties.${s}.data`);
|
|
752
|
+
return f ? {
|
|
773
753
|
...o,
|
|
774
754
|
properties: {
|
|
775
755
|
...o.properties,
|
|
776
756
|
[s]: {
|
|
777
757
|
...l,
|
|
778
|
-
data:
|
|
758
|
+
data: f
|
|
779
759
|
}
|
|
780
760
|
}
|
|
781
761
|
} : o;
|
|
782
762
|
}
|
|
783
|
-
const
|
|
784
|
-
|
|
763
|
+
const c = i.partial(), y = w(
|
|
764
|
+
c,
|
|
785
765
|
e,
|
|
786
766
|
`properties.${s}.data.partial`
|
|
787
767
|
);
|
|
788
768
|
if (!y) return o;
|
|
789
|
-
const p =
|
|
769
|
+
const p = w(
|
|
790
770
|
i,
|
|
791
771
|
{ ...u, ...y },
|
|
792
772
|
`properties.${s}.data`
|
|
@@ -811,8 +791,8 @@ class Pt {
|
|
|
811
791
|
throw new Error("upsertPropertyFromApi: property id is required");
|
|
812
792
|
const o = String(i), l = s.slug ?? void 0;
|
|
813
793
|
await this.setState((u) => {
|
|
814
|
-
const
|
|
815
|
-
...
|
|
794
|
+
const c = u.properties[o], y = c ? {
|
|
795
|
+
...c,
|
|
816
796
|
...l ? { slug: l } : {},
|
|
817
797
|
data: s
|
|
818
798
|
} : {
|
|
@@ -886,7 +866,7 @@ class Pt {
|
|
|
886
866
|
const l = i.properties[o];
|
|
887
867
|
if (!l) return i;
|
|
888
868
|
const u = [
|
|
889
|
-
...l.viewedUnits.filter((
|
|
869
|
+
...l.viewedUnits.filter((c) => c.unitId !== t),
|
|
890
870
|
{ unitId: t, viewedDate: s }
|
|
891
871
|
];
|
|
892
872
|
return {
|
|
@@ -971,7 +951,7 @@ class Pt {
|
|
|
971
951
|
}));
|
|
972
952
|
}
|
|
973
953
|
async setFiltersToDefault() {
|
|
974
|
-
await this.setState((t) => ({ ...t, filters:
|
|
954
|
+
await this.setState((t) => ({ ...t, filters: x }));
|
|
975
955
|
}
|
|
976
956
|
async setApiFilters(t) {
|
|
977
957
|
await this.setState((e) => ({
|
|
@@ -985,37 +965,14 @@ class Pt {
|
|
|
985
965
|
tempFilters: { ...a.tempFilters, [t]: e }
|
|
986
966
|
}));
|
|
987
967
|
}
|
|
988
|
-
async commitTempFilterChange(t, e) {
|
|
989
|
-
const s = (await this.getState()).tempFilters[t] ?? e;
|
|
990
|
-
await this.handleTempFilterChange(t, s), await this.submitFilterUpdate();
|
|
991
|
-
}
|
|
992
|
-
async handleFilterCommitIndexDB(t) {
|
|
993
|
-
await this.setState((e) => {
|
|
994
|
-
const a = {
|
|
995
|
-
...e.apiFilters,
|
|
996
|
-
availability: U(t.availability),
|
|
997
|
-
bedrooms: J(t.bedrooms),
|
|
998
|
-
cost: L(t.cost),
|
|
999
|
-
highlights: U(t.highlights)
|
|
1000
|
-
};
|
|
1001
|
-
return {
|
|
1002
|
-
...e,
|
|
1003
|
-
filters: { ...e.filters, ...t },
|
|
1004
|
-
apiFilters: a
|
|
1005
|
-
};
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
async commitAvailabilityChange() {
|
|
1009
|
-
await this.submitFilterUpdate();
|
|
1010
|
-
}
|
|
1011
968
|
async submitFilterUpdate() {
|
|
1012
969
|
await this.setState((t) => {
|
|
1013
970
|
const e = {
|
|
1014
971
|
...t.apiFilters,
|
|
1015
|
-
availability:
|
|
1016
|
-
bedrooms:
|
|
1017
|
-
cost:
|
|
1018
|
-
highlights:
|
|
972
|
+
availability: H(t.filters.availability),
|
|
973
|
+
bedrooms: bt(t.filters.bedrooms),
|
|
974
|
+
cost: tt(t.filters.cost),
|
|
975
|
+
highlights: H(t.filters.highlights)
|
|
1019
976
|
};
|
|
1020
977
|
return {
|
|
1021
978
|
...t,
|
|
@@ -1065,37 +1022,14 @@ class Pt {
|
|
|
1065
1022
|
return this.getState();
|
|
1066
1023
|
}
|
|
1067
1024
|
async initialize() {
|
|
1068
|
-
await this.setState((t) => ({ ...
|
|
1069
|
-
}
|
|
1070
|
-
async loadPersistedFilters() {
|
|
1071
|
-
}
|
|
1072
|
-
// === LEGACY COMPATIBILITY METHODS ===
|
|
1073
|
-
// Property store compatibility
|
|
1074
|
-
async setData(t) {
|
|
1075
|
-
await this.setState((e) => ({ ...e, properties: t }));
|
|
1076
|
-
}
|
|
1077
|
-
async setPropertySlug(t) {
|
|
1078
|
-
await this.setCurrentPropertySlug(t);
|
|
1079
|
-
}
|
|
1080
|
-
async setPropertyId(t) {
|
|
1081
|
-
await this.setCurrentProperty(t);
|
|
1082
|
-
}
|
|
1083
|
-
async removeData(t) {
|
|
1084
|
-
const e = String(t);
|
|
1085
|
-
await this.setState((a) => {
|
|
1086
|
-
const { [e]: s, ...i } = a.properties;
|
|
1087
|
-
return { ...a, properties: i };
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
async clearData() {
|
|
1091
|
-
await this.setState((t) => ({ ...t, properties: {} }));
|
|
1025
|
+
await this.setState((t) => ({ ...U, ...t }));
|
|
1092
1026
|
}
|
|
1093
1027
|
}
|
|
1094
|
-
const
|
|
1095
|
-
function
|
|
1028
|
+
const d = new Pt();
|
|
1029
|
+
function Ut(r) {
|
|
1096
1030
|
return (t, e) => {
|
|
1097
1031
|
const a = async () => {
|
|
1098
|
-
const i = await
|
|
1032
|
+
const i = await d.getFullState();
|
|
1099
1033
|
t({
|
|
1100
1034
|
properties: i.properties,
|
|
1101
1035
|
currentPropertyId: i.currentPropertyId,
|
|
@@ -1111,7 +1045,7 @@ function Ft(r) {
|
|
|
1111
1045
|
});
|
|
1112
1046
|
}, s = async () => {
|
|
1113
1047
|
if (r != null && r.onFilterUpdate) {
|
|
1114
|
-
const i = (await
|
|
1048
|
+
const i = (await d.getFullState()).apiFilters;
|
|
1115
1049
|
r.onFilterUpdate(i);
|
|
1116
1050
|
}
|
|
1117
1051
|
};
|
|
@@ -1144,55 +1078,55 @@ function Ft(r) {
|
|
|
1144
1078
|
filtersLoaded: !1,
|
|
1145
1079
|
// === PROPERTY OPERATIONS ===
|
|
1146
1080
|
async initializeProperty(i, o) {
|
|
1147
|
-
await
|
|
1081
|
+
await d.initializeProperty(i, o), await a();
|
|
1148
1082
|
},
|
|
1149
1083
|
async setCurrentProperty(i, o) {
|
|
1150
|
-
await
|
|
1084
|
+
await d.setCurrentProperty(i, o), t({
|
|
1151
1085
|
currentPropertyId: i,
|
|
1152
1086
|
...o && { currentPropertySlug: o }
|
|
1153
1087
|
});
|
|
1154
1088
|
},
|
|
1155
1089
|
async setCurrentPropertySlug(i) {
|
|
1156
|
-
await
|
|
1090
|
+
await d.setCurrentPropertySlug(i), t({ currentPropertySlug: i });
|
|
1157
1091
|
},
|
|
1158
1092
|
async setHasPreviouslySearched(i) {
|
|
1159
|
-
await
|
|
1093
|
+
await d.setHasPreviouslySearched(i), await a();
|
|
1160
1094
|
},
|
|
1161
1095
|
async toggleFavorite(i) {
|
|
1162
|
-
await
|
|
1096
|
+
await d.toggleFavorite(i), await a();
|
|
1163
1097
|
},
|
|
1164
1098
|
async markUnitAsViewed(i, o) {
|
|
1165
|
-
await
|
|
1099
|
+
await d.markUnitAsViewed(i, o), await a();
|
|
1166
1100
|
},
|
|
1167
1101
|
async setTourContactedOn() {
|
|
1168
|
-
await
|
|
1102
|
+
await d.setTourContactedOn(), await a();
|
|
1169
1103
|
},
|
|
1170
|
-
getTourContactedOn:
|
|
1104
|
+
getTourContactedOn: d.getTourContactedOn.bind(d),
|
|
1171
1105
|
async setQuestionnaireResults(i) {
|
|
1172
|
-
await
|
|
1106
|
+
await d.setQuestionnaireResults(i), await a();
|
|
1173
1107
|
},
|
|
1174
1108
|
async setTourContactData(i) {
|
|
1175
|
-
await
|
|
1109
|
+
await d.setTourContactData(i), await a();
|
|
1176
1110
|
},
|
|
1177
1111
|
async setUnitResults(i) {
|
|
1178
|
-
await
|
|
1112
|
+
await d.setUnitResults(i), await a();
|
|
1179
1113
|
},
|
|
1180
1114
|
async clearUnitResults() {
|
|
1181
|
-
await
|
|
1115
|
+
await d.clearUnitResults(), await a();
|
|
1182
1116
|
},
|
|
1183
1117
|
// === FILTER OPERATIONS ===
|
|
1184
1118
|
async setFilters(i) {
|
|
1185
|
-
await
|
|
1119
|
+
await d.setFilters(i);
|
|
1186
1120
|
const o = e();
|
|
1187
1121
|
t({ filters: { ...o.filters, ...i } });
|
|
1188
1122
|
},
|
|
1189
1123
|
async setTempFilters(i) {
|
|
1190
|
-
await
|
|
1124
|
+
await d.setTempFilters(i);
|
|
1191
1125
|
const o = e();
|
|
1192
1126
|
t({ tempFilters: { ...o.tempFilters, ...i } });
|
|
1193
1127
|
},
|
|
1194
1128
|
async setFiltersToDefault() {
|
|
1195
|
-
await
|
|
1129
|
+
await d.setFiltersToDefault(), t({ filters: {
|
|
1196
1130
|
availability: void 0,
|
|
1197
1131
|
bedrooms: void 0,
|
|
1198
1132
|
cost: void 0,
|
|
@@ -1200,37 +1134,28 @@ function Ft(r) {
|
|
|
1200
1134
|
} });
|
|
1201
1135
|
},
|
|
1202
1136
|
async setApiFilters(i) {
|
|
1203
|
-
await
|
|
1137
|
+
await d.setApiFilters(i);
|
|
1204
1138
|
const o = e();
|
|
1205
1139
|
t({ apiFilters: { ...o.apiFilters, ...i } });
|
|
1206
1140
|
},
|
|
1207
1141
|
async handleTempFilterChange(i, o) {
|
|
1208
|
-
await
|
|
1142
|
+
await d.handleTempFilterChange(i, o);
|
|
1209
1143
|
const l = e();
|
|
1210
1144
|
t({ tempFilters: { ...l.tempFilters, [i]: o } });
|
|
1211
1145
|
},
|
|
1212
|
-
async commitTempFilterChange(i, o) {
|
|
1213
|
-
await c.commitTempFilterChange(i, o), await a(), await s();
|
|
1214
|
-
},
|
|
1215
|
-
async handleFilterCommitIndexDB(i) {
|
|
1216
|
-
await c.handleFilterCommitIndexDB(i), await a(), await s();
|
|
1217
|
-
},
|
|
1218
|
-
async commitAvailabilityChange() {
|
|
1219
|
-
await c.commitAvailabilityChange(), await a(), await s();
|
|
1220
|
-
},
|
|
1221
1146
|
async submitFilterUpdate() {
|
|
1222
|
-
await
|
|
1147
|
+
await d.submitFilterUpdate(), await a(), await s();
|
|
1223
1148
|
},
|
|
1224
1149
|
// === RESULTS AND SORTING ===
|
|
1225
1150
|
async setResultsMode(i) {
|
|
1226
|
-
await
|
|
1151
|
+
await d.setResultsMode(i), t({ resultsMode: i });
|
|
1227
1152
|
},
|
|
1228
1153
|
async setSortBy(i) {
|
|
1229
|
-
await
|
|
1154
|
+
await d.setSortBy(i), t({ sortBy: i });
|
|
1230
1155
|
},
|
|
1231
1156
|
// === QUESTIONNAIRE ===
|
|
1232
1157
|
async setResolvedQuestionnaireValues(i, o) {
|
|
1233
|
-
await
|
|
1158
|
+
await d.setResolvedQuestionnaireValues(i, o);
|
|
1234
1159
|
const l = e();
|
|
1235
1160
|
t({
|
|
1236
1161
|
resolvedQuestionnaireValues: {
|
|
@@ -1245,37 +1170,18 @@ function Ft(r) {
|
|
|
1245
1170
|
const o = e(), l = o.currentPropertyId ? o.properties[o.currentPropertyId] : null;
|
|
1246
1171
|
return {
|
|
1247
1172
|
isFavorite: (l == null ? void 0 : l.favoritedUnits.includes(i)) ?? !1,
|
|
1248
|
-
viewedDate: ((u = l == null ? void 0 : l.viewedUnits.find((
|
|
1173
|
+
viewedDate: ((u = l == null ? void 0 : l.viewedUnits.find((c) => c.unitId === i)) == null ? void 0 : u.viewedDate) ?? ""
|
|
1249
1174
|
};
|
|
1250
1175
|
},
|
|
1251
|
-
getResultsUrl:
|
|
1252
|
-
getCurrentProperty:
|
|
1253
|
-
getPropertyData:
|
|
1254
|
-
// === LEGACY COMPATIBILITY ===
|
|
1255
|
-
async setData(i) {
|
|
1256
|
-
await c.setData(i), t({ properties: i });
|
|
1257
|
-
},
|
|
1258
|
-
async setPropertySlug(i) {
|
|
1259
|
-
await c.setPropertySlug(i), t({ currentPropertySlug: i });
|
|
1260
|
-
},
|
|
1261
|
-
async setPropertyId(i) {
|
|
1262
|
-
await c.setPropertyId(i), t({ currentPropertyId: i });
|
|
1263
|
-
},
|
|
1264
|
-
async removeData(i) {
|
|
1265
|
-
await c.removeData(i), await a();
|
|
1266
|
-
},
|
|
1267
|
-
async clearData() {
|
|
1268
|
-
await c.clearData(), t({ properties: {} });
|
|
1269
|
-
},
|
|
1270
|
-
async loadPersistedFilters() {
|
|
1271
|
-
await c.loadPersistedFilters(), t({ filtersLoaded: !0 });
|
|
1272
|
-
},
|
|
1176
|
+
getResultsUrl: d.getResultsUrl.bind(d),
|
|
1177
|
+
getCurrentProperty: d.getCurrentProperty.bind(d),
|
|
1178
|
+
getPropertyData: d.getPropertyData.bind(d),
|
|
1273
1179
|
// === INTERNAL ===
|
|
1274
1180
|
async _hydrate() {
|
|
1275
1181
|
await a();
|
|
1276
1182
|
},
|
|
1277
1183
|
async _initialize() {
|
|
1278
|
-
await
|
|
1184
|
+
await d.initialize(), await a(), t({ filtersLoaded: !0 });
|
|
1279
1185
|
}
|
|
1280
1186
|
};
|
|
1281
1187
|
};
|
|
@@ -1283,7 +1189,7 @@ function Ft(r) {
|
|
|
1283
1189
|
function Bt() {
|
|
1284
1190
|
return (r) => (t) => r((e) => e.getUnitState(t));
|
|
1285
1191
|
}
|
|
1286
|
-
function
|
|
1192
|
+
function Ft(r, t) {
|
|
1287
1193
|
return {
|
|
1288
1194
|
property: {
|
|
1289
1195
|
unit: {
|
|
@@ -1307,50 +1213,55 @@ function Ut(r) {
|
|
|
1307
1213
|
set: r.setFilters.bind(r),
|
|
1308
1214
|
setTemp: r.setTempFilters.bind(r),
|
|
1309
1215
|
setToDefault: r.setFiltersToDefault.bind(r),
|
|
1310
|
-
commitTemp:
|
|
1311
|
-
|
|
1216
|
+
commitTemp: async (e, a) => {
|
|
1217
|
+
const i = (t ? t() : r).tempFilters[e] ?? a;
|
|
1218
|
+
await r.handleTempFilterChange(e, i), await r.submitFilterUpdate();
|
|
1219
|
+
},
|
|
1220
|
+
commitAvailability: async () => {
|
|
1221
|
+
await r.submitFilterUpdate();
|
|
1222
|
+
},
|
|
1312
1223
|
submit: r.submitFilterUpdate.bind(r)
|
|
1313
1224
|
}
|
|
1314
1225
|
};
|
|
1315
1226
|
}
|
|
1316
|
-
function
|
|
1227
|
+
function zt(r) {
|
|
1317
1228
|
return (t, e) => {
|
|
1318
|
-
const a =
|
|
1229
|
+
const a = Ut(r)(t, e), s = Ft(a, e);
|
|
1319
1230
|
return {
|
|
1320
1231
|
...a,
|
|
1321
1232
|
...s
|
|
1322
1233
|
};
|
|
1323
1234
|
};
|
|
1324
1235
|
}
|
|
1325
|
-
const
|
|
1236
|
+
const Lt = {
|
|
1326
1237
|
async isFavorite(r, t) {
|
|
1327
1238
|
return St(r, t);
|
|
1328
1239
|
},
|
|
1329
1240
|
async toggle(r, t) {
|
|
1330
|
-
return
|
|
1241
|
+
return ht(r, t);
|
|
1331
1242
|
},
|
|
1332
1243
|
async set(r, t, e) {
|
|
1333
|
-
return
|
|
1244
|
+
return Z(r, t, e);
|
|
1334
1245
|
},
|
|
1335
1246
|
async getAll(r) {
|
|
1336
|
-
return
|
|
1247
|
+
return z(r);
|
|
1337
1248
|
}
|
|
1338
|
-
},
|
|
1249
|
+
}, et = "//web.inresiapp.com", rt = "/placeholder.jpg", It = (r) => r ? r.startsWith("?") ? r : `?${r}` : "", kt = (r, t, e = et) => `${e}/${t}/unit/${r}/explore`, $ = (r, t = rt) => !(r != null && r.CFURL) || !(r != null && r.name) || !(r != null && r.signature) ? t : `${r.CFURL}${r.name}${It(r.signature)}`;
|
|
1339
1250
|
function Qt(r) {
|
|
1340
1251
|
return { data: r };
|
|
1341
1252
|
}
|
|
1342
1253
|
function Ht(r, t, e) {
|
|
1343
1254
|
var o, l;
|
|
1344
|
-
const a = (e == null ? void 0 : e.origin) ??
|
|
1345
|
-
var
|
|
1346
|
-
const
|
|
1255
|
+
const a = (e == null ? void 0 : e.origin) ?? et, s = (e == null ? void 0 : e.placeholderImage) ?? rt, i = ((o = r.hits) == null ? void 0 : o.map((u) => {
|
|
1256
|
+
var f, L;
|
|
1257
|
+
const c = u._source ?? {}, y = typeof c.name == "string" ? c.name : typeof c.title == "string" ? c.title : "";
|
|
1347
1258
|
return {
|
|
1348
|
-
...
|
|
1259
|
+
...c,
|
|
1349
1260
|
title: y,
|
|
1350
|
-
slug:
|
|
1351
|
-
imageUrl:
|
|
1352
|
-
secondaryImageUrl:
|
|
1353
|
-
tertiaryImageUrl:
|
|
1261
|
+
slug: kt(String(c.slug ?? ""), t, a),
|
|
1262
|
+
imageUrl: $(c.image, s),
|
|
1263
|
+
secondaryImageUrl: $((f = c.additionalImages) == null ? void 0 : f[0], s),
|
|
1264
|
+
tertiaryImageUrl: $((L = c.additionalImages) == null ? void 0 : L[1], s)
|
|
1354
1265
|
};
|
|
1355
1266
|
})) ?? [];
|
|
1356
1267
|
return {
|
|
@@ -1360,7 +1271,7 @@ function Ht(r, t, e) {
|
|
|
1360
1271
|
hits: i
|
|
1361
1272
|
};
|
|
1362
1273
|
}
|
|
1363
|
-
const
|
|
1274
|
+
const Rt = {
|
|
1364
1275
|
asap: "ASAP",
|
|
1365
1276
|
next_month: "Next Month",
|
|
1366
1277
|
"2_3_months": "2-3 Months",
|
|
@@ -1370,7 +1281,7 @@ const kt = {
|
|
|
1370
1281
|
1: "1 Bed",
|
|
1371
1282
|
2: "2 Bed",
|
|
1372
1283
|
3: "3+ Bed"
|
|
1373
|
-
},
|
|
1284
|
+
}, Dt = new Set(Object.values(k)), At = (r) => {
|
|
1374
1285
|
if (!r || r.length === 0) return;
|
|
1375
1286
|
const t = /* @__PURE__ */ new Set();
|
|
1376
1287
|
for (const e of r) {
|
|
@@ -1382,13 +1293,13 @@ const kt = {
|
|
|
1382
1293
|
const a = e.split(",").map((s) => s.trim());
|
|
1383
1294
|
for (const s of a) {
|
|
1384
1295
|
const i = Number.parseInt(s, 10);
|
|
1385
|
-
!Number.isNaN(i) && k[i] ? t.add(k[i]) :
|
|
1296
|
+
!Number.isNaN(i) && k[i] ? t.add(k[i]) : Dt.has(s) && t.add(s);
|
|
1386
1297
|
}
|
|
1387
1298
|
}
|
|
1388
1299
|
return t.size > 0 ? Array.from(t) : void 0;
|
|
1389
1300
|
}, qt = (r) => ({
|
|
1390
1301
|
availability: r.availability && r.availability.length > 0 ? r.availability.map(
|
|
1391
|
-
(e) =>
|
|
1302
|
+
(e) => Rt[e] ?? e
|
|
1392
1303
|
) : void 0,
|
|
1393
1304
|
bedrooms: At(r.bedrooms),
|
|
1394
1305
|
cost: r.cost ?? void 0,
|
|
@@ -1397,57 +1308,55 @@ const kt = {
|
|
|
1397
1308
|
export {
|
|
1398
1309
|
Mt as ApiUserSchema,
|
|
1399
1310
|
Tt as AppStoreDataSchema,
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1311
|
+
rt as DEFAULT_PLACEHOLDER_IMAGE,
|
|
1312
|
+
et as DEFAULT_WEB_ORIGIN,
|
|
1313
|
+
j as FavoritesSchema,
|
|
1314
|
+
D as FiltersSchema,
|
|
1315
|
+
it as OpenDBError,
|
|
1405
1316
|
v as PropertySchema,
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1317
|
+
mt as PropertyStore,
|
|
1318
|
+
C as PropertyStoreDataSchema,
|
|
1319
|
+
q as QueryParamsSchema,
|
|
1320
|
+
J as ResultsModeEnum,
|
|
1321
|
+
F as SCHEMA_VERSION,
|
|
1322
|
+
at as SchemaMismatchError,
|
|
1323
|
+
G as SortByEnum,
|
|
1413
1324
|
Pt as Store,
|
|
1414
|
-
|
|
1325
|
+
ct as TourContactDataSchema,
|
|
1415
1326
|
Pt as UnifiedStore,
|
|
1416
|
-
|
|
1417
|
-
|
|
1327
|
+
O as UnifiedStoreDataSchema,
|
|
1328
|
+
ot as UnitDataSchema,
|
|
1418
1329
|
Et as UnitFavoriteSchema,
|
|
1419
1330
|
b as UnitSchema,
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1331
|
+
A as UserPropertyStateSchema,
|
|
1332
|
+
S as UserSchema,
|
|
1333
|
+
st as UserUnitDataSchema,
|
|
1334
|
+
ut as ViewedUnitSchema,
|
|
1335
|
+
kt as buildExploreUrl,
|
|
1336
|
+
$ as buildImageUrl,
|
|
1337
|
+
dt as configureValidation,
|
|
1338
|
+
_t as createORMStringStorage,
|
|
1339
|
+
zt as createStructuredStore,
|
|
1340
|
+
Ft as createStructuredStoreActions,
|
|
1430
1341
|
Bt as createUseUnitState,
|
|
1431
|
-
|
|
1432
|
-
Ft as createZustandStore,
|
|
1433
|
-
Ft as createZustandUnifiedStore,
|
|
1342
|
+
Ut as createZustandUnifiedStore,
|
|
1434
1343
|
wt as debugDump,
|
|
1435
|
-
|
|
1436
|
-
|
|
1344
|
+
gt as defaultIdGenerator,
|
|
1345
|
+
B as ensureUser,
|
|
1437
1346
|
jt as exportJSON,
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1347
|
+
Lt as favorites,
|
|
1348
|
+
g as getDB,
|
|
1349
|
+
z as getFavoritedUnitsForProperty,
|
|
1441
1350
|
$t as getUserUUID,
|
|
1442
1351
|
St as isUnitFavorited,
|
|
1443
|
-
|
|
1352
|
+
K as kvGet,
|
|
1444
1353
|
Nt as kvRemove,
|
|
1445
|
-
|
|
1446
|
-
|
|
1354
|
+
W as kvSet,
|
|
1355
|
+
xt as propertyStore,
|
|
1447
1356
|
Vt as resetDB,
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1357
|
+
Z as setFavoriteUnit,
|
|
1358
|
+
d as store,
|
|
1359
|
+
ht as toggleFavoriteUnit,
|
|
1451
1360
|
Qt as transformUnitsApiResponse,
|
|
1452
1361
|
Ht as transformUnitsApiResponseToClient,
|
|
1453
1362
|
qt as transformUnitsApiResponseToClientFilters
|